use new field api

This commit is contained in:
Gael Pasgrimaud
2011-03-25 01:21:28 +01:00
parent d76b85a3e2
commit 9d0faeea17
9 changed files with 81 additions and 155 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
newest = false
extensions = gp.vcsdevelop
parts = eggs test
develop = . pyramidapp ../fa.jquery
develop = . pyramidapp ../fa.jquery ../formalchemy
[eggs]
recipe = zc.recipe.egg
@@ -8,10 +8,7 @@
<div class="label" tal:condition="field.requires_label">
<div tal:condition="isinstance(field.type, fatypes.Boolean)"
tal:content="structure field.render()" />
<label tal:attributes="class field.is_required() and 'field_req' or 'field_opt';
for field.renderer.name">
<span tal:replace="[field.label_text, fieldset.prettify(field.key)][int(field.label_text is None)]" />
</label>
<label tal:replace="structure field.label_tag()" />
</div>
<div class="fa_instructions ui-corner-all"
tal:content="field.metadata['instructions']"
@@ -4,20 +4,19 @@ def bind():
_lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.')
_init_scope = _loads('cchameleon.core.utils\necontext\np1\n.')
_re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.")
_attrs_4356305168 = _loads('(dp1\nVclass\np2\nVfield_input\np3\ns.')
_attrs_4356308368 = _loads('(dp1\nVclass\np2\nVfa_instructions ui-corner-all\np3\ns.')
_attrs_4356306896 = _loads('(dp1\n.')
_attrs_4356307792 = _loads('(dp1\nVclass\np2\nVlabel\np3\ns.')
_attrs_4355399760 = _loads('(dp1\n.')
_attrs_4355400208 = _loads('(dp1\nVclass\np2\nVfa_instructions ui-corner-all\np3\ns.')
_attrs_4355399888 = _loads('(dp1\n.')
_attrs_4355400144 = _loads('(dp1\nVclass\np2\nVlabel\np3\ns.')
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
_attrs_4356308560 = _loads('(dp1\n.')
_attrs_4356307152 = _loads('(dp1\n.')
_attrs_4356305488 = _loads('(dp1\n.')
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
_attrs_4356307536 = _loads('(dp1\nVclass\np2\nVfa_field ui-widget\np3\ns.')
_attrs_4356308240 = _loads('(dp1\n.')
_attrs_4356305040 = _loads('(dp1\n.')
_attrs_4355400400 = _loads('(dp1\nVclass\np2\nVui-state-error ui-corner-all\np3\ns.')
_attrs_4355400080 = _loads('(dp1\n.')
_attrs_4355400464 = _loads('(dp1\nVclass\np2\nVfield_input\np3\ns.')
_attrs_4355400528 = _loads('(dp1\n.')
_attrs_4355400016 = _loads('(dp1\nVclass\np2\nVfa_field ui-widget\np3\ns.')
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
_attrs_4356308944 = _loads('(dp1\nVclass\np2\nVui-state-error ui-corner-all\np3\ns.')
_attrs_4355400272 = _loads('(dp1\n.')
def render(econtext, rcontext=None):
macros = econtext.get('macros')
_translate = econtext.get('_translate')
@@ -40,7 +39,7 @@ def bind():
_tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'errors'), 'get')(None, False)
if _tmp1:
pass
attrs = _attrs_4356306896
attrs = _attrs_4355399760
u"''"
_write(u'<div>\n ')
_default.value = default = ''
@@ -52,7 +51,7 @@ def bind():
_tmp2 = (_tmp2 - 1)
u'error'
_content = error
attrs = _attrs_4356307152
attrs = _attrs_4355399888
u'_content'
_write(u'<div>')
_tmp3 = _content
@@ -92,13 +91,13 @@ def bind():
for field in _tmp1:
_tmp2 = (_tmp2 - 1)
_write(u'\n ')
attrs = _attrs_4356307536
attrs = _attrs_4355400016
u'field.requires_label'
_write(u'<div class="fa_field ui-widget">\n ')
_tmp3 = _lookup_attr(field, 'requires_label')
if _tmp3:
pass
attrs = _attrs_4356307792
attrs = _attrs_4355400144
u"''"
_write(u'<div class="label">\n ')
_default.value = default = ''
@@ -108,7 +107,7 @@ def bind():
pass
u'field.render()'
_content = _lookup_attr(field, 'render')()
attrs = _attrs_4356308560
attrs = _attrs_4355400272
u'_content'
_write(u'<div>')
_tmp3 = _content
@@ -127,58 +126,11 @@ def bind():
_tmp = str(_tmp)
_write(_tmp)
_write(u'</div>')
_write(u'\n ')
attrs = _attrs_4356305040
u"field.is_required() and 'field_req' or 'field_opt'"
_write(u'<label')
_tmp3 = ((_lookup_attr(field, 'is_required')() and 'field_req') or 'field_opt')
if (_tmp3 is _default):
_tmp3 = None
if ((_tmp3 is not None) and (_tmp3 is not False)):
if (_tmp3.__class__ not in (str, unicode, int, float, )):
_tmp3 = unicode(_translate(_tmp3, domain=_domain, mapping=None, target_language=target_language, default=None))
else:
if not isinstance(_tmp3, unicode):
_tmp3 = str(_tmp3)
if ('&' in _tmp3):
if (';' in _tmp3):
_tmp3 = _re_amp.sub('&amp;', _tmp3)
else:
_tmp3 = _tmp3.replace('&', '&amp;')
if ('<' in _tmp3):
_tmp3 = _tmp3.replace('<', '&lt;')
if ('>' in _tmp3):
_tmp3 = _tmp3.replace('>', '&gt;')
if ('"' in _tmp3):
_tmp3 = _tmp3.replace('"', '&quot;')
_write(((' class="' + _tmp3) + '"'))
u'field.renderer.name'
_tmp3 = _lookup_attr(_lookup_attr(field, 'renderer'), 'name')
if (_tmp3 is _default):
_tmp3 = None
if ((_tmp3 is not None) and (_tmp3 is not False)):
if (_tmp3.__class__ not in (str, unicode, int, float, )):
_tmp3 = unicode(_translate(_tmp3, domain=_domain, mapping=None, target_language=target_language, default=None))
else:
if not isinstance(_tmp3, unicode):
_tmp3 = str(_tmp3)
if ('&' in _tmp3):
if (';' in _tmp3):
_tmp3 = _re_amp.sub('&amp;', _tmp3)
else:
_tmp3 = _tmp3.replace('&', '&amp;')
if ('<' in _tmp3):
_tmp3 = _tmp3.replace('<', '&lt;')
if ('>' in _tmp3):
_tmp3 = _tmp3.replace('>', '&gt;')
if ('"' in _tmp3):
_tmp3 = _tmp3.replace('"', '&quot;')
_write(((' for="' + _tmp3) + '"'))
u"''"
_write(u'>\n ')
_write(u'\n ')
_default.value = default = ''
u'[field.label_text, fieldset.prettify(field.key)][int(field.label_text is None)]'
_content = [_lookup_attr(field, 'label_text'), _lookup_attr(econtext['fieldset'], 'prettify')(_lookup_attr(field, 'key')), ][int((_lookup_attr(field, 'label_text') is None))]
u'field.label_tag()'
_content = _lookup_attr(field, 'label_tag')()
u'_content'
_tmp3 = _content
_tmp = _tmp3
@@ -194,17 +146,8 @@ def bind():
if (_tmp is not None):
if not isinstance(_tmp, unicode):
_tmp = str(_tmp)
if ('&' in _tmp):
if (';' in _tmp):
_tmp = _re_amp.sub('&amp;', _tmp)
else:
_tmp = _tmp.replace('&', '&amp;')
if ('<' in _tmp):
_tmp = _tmp.replace('<', '&lt;')
if ('>' in _tmp):
_tmp = _tmp.replace('>', '&gt;')
_write(_tmp)
_write(u'\n </label>\n </div>')
_write(u'\n </div>')
u"u'\\n '"
_write(u'\n ')
_default.value = default = u'\n '
@@ -214,7 +157,7 @@ def bind():
pass
u"field.metadata['instructions']"
_content = _lookup_attr(field, 'metadata')['instructions']
attrs = _attrs_4356308368
attrs = _attrs_4355400208
u'_content'
_write(u'<div class="fa_instructions ui-corner-all">')
_tmp3 = _content
@@ -247,7 +190,7 @@ def bind():
_tmp3 = _lookup_attr(field, 'errors')
if _tmp3:
pass
attrs = _attrs_4356308944
attrs = _attrs_4355400400
u"''"
_write(u'<div class="ui-state-error ui-corner-all">\n ')
_default.value = default = ''
@@ -259,7 +202,7 @@ def bind():
_tmp4 = (_tmp4 - 1)
u'error'
_content = error
attrs = _attrs_4356305488
attrs = _attrs_4355400528
u'_content'
_write(u'<div>')
_tmp5 = _content
@@ -300,7 +243,7 @@ def bind():
pass
u'field.render()'
_content = _lookup_attr(field, 'render')()
attrs = _attrs_4356305168
attrs = _attrs_4355400464
u'_content'
_write(u'<div class="field_input">')
_tmp3 = _content
@@ -324,7 +267,7 @@ def bind():
_tmp3 = (not _lookup_attr(field, 'is_readonly')() and ((_lookup_attr(econtext['fieldset'], 'focus') == field) or (_lookup_attr(econtext['fieldset'], 'focus') is True)) and not focus_rendered)
if _tmp3:
pass
attrs = _attrs_4356308240
attrs = _attrs_4355400080
u'True'
_write(u'<script>\n ')
focus_rendered = True
@@ -2,8 +2,7 @@
<tal:field tal:repeat="field fieldset.render_fields.itervalues()">
<tr tal:condition="field.requires_label">
<td class="field_readonly">
<label tal:content="[field.label_text, fieldset.prettify(field.key)][int(field.label_text is None)]"
/>
<label tal:replace="structure field.label_tag()" />
</td>
<td tal:content="structure field.render_readonly()" />
</tr>
@@ -1,20 +1,18 @@
registry = dict(version=0)
def bind():
from cPickle import loads as _loads
_attrs_4356060816 = _loads('(dp1\n.')
_lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.')
_init_scope = _loads('cchameleon.core.utils\necontext\np1\n.')
_re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.")
_attrs_4356061264 = _loads('(dp1\nVclass\np2\nVfield_readonly\np3\ns.')
_attrs_4356060176 = _loads('(dp1\n.')
_attrs_4356061008 = _loads('(dp1\n.')
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
_attrs_4356061968 = _loads('(dp1\n.')
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
_attrs_4356061392 = _loads('(dp1\nVstyle\np2\nVdisplay:none\np3\ns.')
_attrs_4356062096 = _loads('(dp1\n.')
_attrs_4356059600 = _loads('(dp1\n.')
_attrs_4355418576 = _loads('(dp1\nVstyle\np2\nVdisplay:none\np3\ns.')
_attrs_4355401296 = _loads('(dp1\n.')
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
_attrs_4355399952 = _loads('(dp1\n.')
_attrs_4355441232 = _loads('(dp1\n.')
_attrs_4355400784 = _loads('(dp1\n.')
_attrs_4355400912 = _loads('(dp1\nVclass\np2\nVfield_readonly\np3\ns.')
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
_attrs_4355400848 = _loads('(dp1\n.')
def render(econtext, rcontext=None):
macros = econtext.get('macros')
_translate = econtext.get('_translate')
@@ -30,7 +28,7 @@ def bind():
default = None
u'None'
_domain = None
attrs = _attrs_4356062096
attrs = _attrs_4355441232
u'fieldset.render_fields.itervalues()'
_write(u'<tbody>\n ')
_tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'render_fields'), 'itervalues')()
@@ -43,17 +41,15 @@ def bind():
_tmp3 = _lookup_attr(field, 'requires_label')
if _tmp3:
pass
attrs = _attrs_4356061968
attrs = _attrs_4355401296
_write(u'<tr>\n ')
attrs = _attrs_4356061264
attrs = _attrs_4355400912
u"''"
_write(u'<td class="field_readonly">\n ')
_default.value = default = ''
u'[field.label_text, fieldset.prettify(field.key)][int(field.label_text is None)]'
_content = [_lookup_attr(field, 'label_text'), _lookup_attr(econtext['fieldset'], 'prettify')(_lookup_attr(field, 'key')), ][int((_lookup_attr(field, 'label_text') is None))]
attrs = _attrs_4356061008
u'field.label_tag()'
_content = _lookup_attr(field, 'label_tag')()
u'_content'
_write(u'<label>')
_tmp3 = _content
_tmp = _tmp3
if (_tmp.__class__ not in (str, unicode, int, float, )):
@@ -68,22 +64,13 @@ def bind():
if (_tmp is not None):
if not isinstance(_tmp, unicode):
_tmp = str(_tmp)
if ('&' in _tmp):
if (';' in _tmp):
_tmp = _re_amp.sub('&amp;', _tmp)
else:
_tmp = _tmp.replace('&', '&amp;')
if ('<' in _tmp):
_tmp = _tmp.replace('<', '&lt;')
if ('>' in _tmp):
_tmp = _tmp.replace('>', '&gt;')
_write(_tmp)
u"''"
_write(u'</label>\n </td>\n ')
_write(u'\n </td>\n ')
_default.value = default = ''
u'field.render_readonly()'
_content = _lookup_attr(field, 'render_readonly')()
attrs = _attrs_4356060176
attrs = _attrs_4355400848
u'_content'
_write(u'<td>')
_tmp3 = _content
@@ -107,11 +94,11 @@ def bind():
break
_write(' ')
_write(u'\n ')
attrs = _attrs_4356061392
attrs = _attrs_4355418576
_write(u'<tr style="display:none">')
attrs = _attrs_4356059600
attrs = _attrs_4355400784
_write(u'<td>&nbsp;</td>')
attrs = _attrs_4356060816
attrs = _attrs_4355399952
u'fieldset.render_fields.itervalues()'
_write(u'<td>\n ')
_tmp1 = _lookup_attr(_lookup_attr(econtext['fieldset'], 'render_fields'), 'itervalues')()
+1 -1
View File
@@ -2,7 +2,7 @@
<thead>
<tr class="ui-widget-header">
<th tal:repeat="field collection.render_fields.itervalues()"
tal:content="field.label_text or collection.prettify(field.key)"></th>
tal:content="field.label()"></th>
</tr>
</thead>
<tbody>
+18 -18
View File
@@ -4,17 +4,17 @@ def bind():
_lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.')
_init_scope = _loads('cchameleon.core.utils\necontext\np1\n.')
_re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.")
_attrs_4360343760 = _loads('(dp1\nVclass\np2\nVgrid_error\np3\ns.')
_attrs_4360326480 = _loads('(dp1\nVclass\np2\nVui-widget-header\np3\ns.')
_attrs_4360326992 = _loads('(dp1\n.')
_attrs_4360326352 = _loads('(dp1\n.')
_attrs_4361422096 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.')
_attrs_4361422992 = _loads('(dp1\n.')
_attrs_4361422800 = _loads('(dp1\n.')
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
_attrs_4360326608 = _loads('(dp1\n.')
_attrs_4360326096 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.')
_attrs_4361422352 = _loads('(dp1\n.')
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
_attrs_4360326416 = _loads('(dp1\n.')
_attrs_4361422416 = _loads('(dp1\n.')
_attrs_4361422480 = _loads('(dp1\nVclass\np2\nVui-widget-header\np3\ns.')
_attrs_4361422608 = _loads('(dp1\n.')
_attrs_4361423312 = _loads('(dp1\nVclass\np2\nVgrid_error\np3\ns.')
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
_attrs_4360326800 = _loads('(dp1\n.')
def render(econtext, rcontext=None):
macros = econtext.get('macros')
_translate = econtext.get('_translate')
@@ -30,11 +30,11 @@ def bind():
default = None
u'None'
_domain = None
attrs = _attrs_4360326096
attrs = _attrs_4361422096
_write(u'<table class="layout-grid">\n')
attrs = _attrs_4360326352
attrs = _attrs_4361422352
_write(u'<thead>\n ')
attrs = _attrs_4360326480
attrs = _attrs_4361422480
u"''"
_write(u'<tr class="ui-widget-header">\n ')
_default.value = default = ''
@@ -44,9 +44,9 @@ def bind():
(_tmp1, _tmp2, ) = repeat.insert('field', _tmp1)
for field in _tmp1:
_tmp2 = (_tmp2 - 1)
u'field.label_text or collection.prettify(field.key)'
_content = (_lookup_attr(field, 'label_text') or _lookup_attr(econtext['collection'], 'prettify')(_lookup_attr(field, 'key')))
attrs = _attrs_4360326608
u'field.label()'
_content = _lookup_attr(field, 'label')()
attrs = _attrs_4361422608
u'_content'
_write(u'<th>')
_tmp3 = _content
@@ -78,7 +78,7 @@ def bind():
break
_write(' ')
_write(u'\n </tr>\n</thead>\n')
attrs = _attrs_4360326416
attrs = _attrs_4361422416
u'collection.rows'
_write(u'<tbody>\n ')
_tmp1 = _lookup_attr(econtext['collection'], 'rows')
@@ -91,7 +91,7 @@ def bind():
dummy = _lookup_attr(econtext['collection'], '_set_active')(row)
u'collection.get_errors(row)'
row_errors = _lookup_attr(econtext['collection'], 'get_errors')(row)
attrs = _attrs_4360326800
attrs = _attrs_4361422800
u"ui-widget-${repeat.row.even and 'even' or 'odd'}"
_write(u'<tr')
_tmp3 = ('%s%s' % (u'ui-widget-', ((_lookup_attr(repeat.row, 'even') and 'even') or 'odd'), ))
@@ -122,7 +122,7 @@ def bind():
(_tmp3, _tmp4, ) = repeat.insert('field', _tmp3)
for field in _tmp3:
_tmp4 = (_tmp4 - 1)
attrs = _attrs_4360326992
attrs = _attrs_4361422992
u"''"
_write(u'<td>\n ')
_default.value = default = ''
@@ -151,7 +151,7 @@ def bind():
(_tmp5, _tmp6, ) = repeat.insert('error', _tmp5)
for error in _tmp5:
_tmp6 = (_tmp6 - 1)
attrs = _attrs_4360343760
attrs = _attrs_4361423312
u'error'
_write(u'<div class="grid_error">')
_tmp7 = error
@@ -2,7 +2,7 @@
<thead>
<tr class="ui-widget-header">
<th tal:repeat="field collection.render_fields.itervalues()"
tal:content="field.label_text or collection.prettify(field.key)"></th>
tal:content="field.label()"></th>
</tr>
</thead>
<tbody>
@@ -4,15 +4,15 @@ def bind():
_lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.')
_init_scope = _loads('cchameleon.core.utils\necontext\np1\n.')
_re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.")
_attrs_4356110736 = _loads('(dp1\n.')
_attrs_4356108432 = _loads('(dp1\n.')
_attrs_4356108624 = _loads('(dp1\n.')
_attrs_4356214992 = _loads('(dp1\n.')
_attrs_4356111376 = _loads('(dp1\n.')
_attrs_4356384400 = _loads('(dp1\nVclass\np2\nVui-widget-header\np3\ns.')
_attrs_4356384336 = _loads('(dp1\n.')
_attrs_4356384272 = _loads('(dp1\n.')
_attrs_4356384528 = _loads('(dp1\n.')
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
_attrs_4356108496 = _loads('(dp1\nVclass\np2\nVui-widget-header\np3\ns.')
_attrs_4356215312 = _loads('(dp1\n.')
_attrs_4356384912 = _loads('(dp1\n.')
_attrs_4356384720 = _loads('(dp1\n.')
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
_attrs_4356384016 = _loads('(dp1\n.')
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
def render(econtext, rcontext=None):
macros = econtext.get('macros')
@@ -29,11 +29,11 @@ def bind():
default = None
u'None'
_domain = None
attrs = _attrs_4356108624
attrs = _attrs_4356384016
_write(u'<table>\n ')
attrs = _attrs_4356111376
attrs = _attrs_4356384272
_write(u'<thead>\n ')
attrs = _attrs_4356108496
attrs = _attrs_4356384400
u"''"
_write(u'<tr class="ui-widget-header">\n ')
_default.value = default = ''
@@ -43,9 +43,9 @@ def bind():
(_tmp1, _tmp2, ) = repeat.insert('field', _tmp1)
for field in _tmp1:
_tmp2 = (_tmp2 - 1)
u'field.label_text or collection.prettify(field.key)'
_content = (_lookup_attr(field, 'label_text') or _lookup_attr(econtext['collection'], 'prettify')(_lookup_attr(field, 'key')))
attrs = _attrs_4356108432
u'field.label()'
_content = _lookup_attr(field, 'label')()
attrs = _attrs_4356384528
u'_content'
_write(u'<th>')
_tmp3 = _content
@@ -77,7 +77,7 @@ def bind():
break
_write(' ')
_write(u'\n </tr>\n </thead>\n ')
attrs = _attrs_4356110736
attrs = _attrs_4356384336
u'collection.rows'
_write(u'<tbody>\n ')
_tmp1 = _lookup_attr(econtext['collection'], 'rows')
@@ -88,7 +88,7 @@ def bind():
u'collection._set_active(row)'
_write(u'')
dummy = _lookup_attr(econtext['collection'], '_set_active')(row)
attrs = _attrs_4356214992
attrs = _attrs_4356384720
u"ui-widget-${repeat.row.even and 'even' or 'odd'}"
_write(u'<tr')
_tmp3 = ('%s%s' % (u'ui-widget-', ((_lookup_attr(repeat.row, 'even') and 'even') or 'odd'), ))
@@ -123,7 +123,7 @@ def bind():
_tmp4 = (_tmp4 - 1)
u'field.render_readonly()'
_content = _lookup_attr(field, 'render_readonly')()
attrs = _attrs_4356215312
attrs = _attrs_4356384912
u'_content'
_write(u'<td>')
_tmp5 = _content