mirror of
https://github.com/wassname/pyramid_formalchemy.git
synced 2026-06-27 16:10:40 +08:00
add config.formalchemy_model()
This commit is contained in:
@@ -20,6 +20,7 @@ eggs =
|
||||
recipe = zc.recipe.egg
|
||||
eggs =
|
||||
${eggs:eggs}
|
||||
unittest2
|
||||
nose
|
||||
initialization =
|
||||
import os
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pyramid.httpexceptions import HTTPFound
|
||||
from pyramid_formalchemy.resources import Models
|
||||
|
||||
def includeme(config):
|
||||
"""include formalchemy's zcml"""
|
||||
config.add_static_view('fa_admin', 'pyramid_formalchemy:static')
|
||||
config.add_directive('formalchemy_admin', 'pyramid_formalchemy.formalchemy_admin')
|
||||
config.add_directive('formalchemy_model', 'pyramid_formalchemy.formalchemy_model')
|
||||
|
||||
def formalchemy_model(config, route_name,
|
||||
factory='pyramid_formalchemy.resources.ModelListing',
|
||||
view='pyramid_formalchemy.views.ModelView',
|
||||
package=None, model=None, forms=None, session_factory=None, **kwargs):
|
||||
model = config.maybe_dotted(model)
|
||||
return formalchemy_admin(config, route_name, factory=factory, view=view, package=package,
|
||||
models=[model], model=model, forms=forms, session_factory=session_factory, **kwargs)
|
||||
|
||||
def formalchemy_admin(config, route_name,
|
||||
factory='pyramid_formalchemy.resources.Models',
|
||||
view='pyramid_formalchemy.views.ModelView',
|
||||
package=None, models=None, forms=None, session_factory=None):
|
||||
package=None, models=None, forms=None, session_factory=None, **kwargs):
|
||||
"""configure formalchemy's admin interface"""
|
||||
|
||||
route_name = route_name.strip('/')
|
||||
|
||||
kw = dict(route_name=route_name, view=view)
|
||||
|
||||
if models:
|
||||
@@ -30,8 +42,9 @@ def formalchemy_admin(config, route_name,
|
||||
session_factory = config.maybe_dotted('%s.models.DBSession' % package)
|
||||
|
||||
factory_args = {
|
||||
'__models__': models,
|
||||
'__forms__': forms,
|
||||
'__models__': models,
|
||||
'__model_class__': kwargs.get('model'),
|
||||
'__session_factory__': session_factory,
|
||||
'__fa_route_name__': route_name,
|
||||
}
|
||||
@@ -41,19 +54,24 @@ def formalchemy_admin(config, route_name,
|
||||
factory = type('%s_%s' % (factory.__name__, route_name), (factory,), factory_args)
|
||||
|
||||
def redirect(request):
|
||||
return HTTPFound(location='%s/%s/' % (request.application_url, route_name))
|
||||
"""redirect /route_name to /route_name/"""
|
||||
matchdict = request.matchdict.copy()
|
||||
url = request.route_url(route_name, traverse=(), **matchdict)
|
||||
return HTTPFound(location=url)
|
||||
|
||||
config.add_route('%s_redirect' % route_name, route_name, redirect)
|
||||
|
||||
config.add_route(route_name, '%s/*traverse' % route_name,
|
||||
factory=factory)
|
||||
|
||||
config.add_view(context=factory,
|
||||
renderer='pyramid_formalchemy:templates/admin/models.pt',
|
||||
attr='models',
|
||||
request_method='GET',
|
||||
permission='view',
|
||||
**kw)
|
||||
if issubclass(factory, Models):
|
||||
# don't want all models
|
||||
config.add_view(context=factory,
|
||||
renderer='pyramid_formalchemy:templates/admin/models.pt',
|
||||
attr='models',
|
||||
request_method='GET',
|
||||
permission='view',
|
||||
**kw)
|
||||
|
||||
config.add_view(context='pyramid_formalchemy.resources.ModelListing',
|
||||
renderer='pyramid_formalchemy:templates/admin/listing.pt',
|
||||
|
||||
@@ -13,14 +13,18 @@ class Base(object):
|
||||
if hasattr(self, '__fa_route_name__'):
|
||||
request.session_factory = self.__session_factory__
|
||||
request.route_name = self.__fa_route_name__
|
||||
request.model = self.__models__
|
||||
request.models = self.__models__
|
||||
request.forms = self.__forms__
|
||||
request.fa_url = self.fa_url
|
||||
request.model_instance = None
|
||||
request.model_class = None
|
||||
request.model_name = None
|
||||
request.model_id = None
|
||||
request.relation = None
|
||||
request.format = 'html'
|
||||
if self.__model_class__:
|
||||
request.model_class = self.__model_class__
|
||||
request.model_name = self.__model_class__.__name__
|
||||
|
||||
def get_model(self):
|
||||
request = self.request
|
||||
@@ -28,13 +32,13 @@ class Base(object):
|
||||
return request.model_class
|
||||
model_name = request.model_name
|
||||
model_class = None
|
||||
if isinstance(request.model, list):
|
||||
for model in request.model:
|
||||
if isinstance(request.models, list):
|
||||
for model in request.models:
|
||||
if model.__name__ == model_name:
|
||||
model_class = model
|
||||
break
|
||||
elif hasattr(request.model, model_name):
|
||||
model_class = getattr(request.model, model_name)
|
||||
elif hasattr(request.models, model_name):
|
||||
model_class = getattr(request.models, model_name)
|
||||
if model_class is None:
|
||||
raise NotFound()
|
||||
request.model_class = model_class
|
||||
@@ -45,6 +49,14 @@ class Base(object):
|
||||
session = self.request.session_factory()
|
||||
return session.query(model).get(self.request.model_id)
|
||||
|
||||
def _fa_url(self, *args):
|
||||
matchdict = self.request.matchdict.copy()
|
||||
if 'traverse' in matchdict:
|
||||
del matchdict['traverse']
|
||||
return self.request.route_url(self.__fa_route_name__,
|
||||
traverse=tuple([str(a) for a in args]),
|
||||
**matchdict)
|
||||
|
||||
|
||||
|
||||
class Models(Base):
|
||||
@@ -53,8 +65,7 @@ class Models(Base):
|
||||
Base.__init__(self, request, None)
|
||||
|
||||
def fa_url(self, *args):
|
||||
return self.request.route_url(self.__fa_route_name__,
|
||||
traverse='/'.join([str(a) for a in args]))
|
||||
return self._fa_url(*args)
|
||||
|
||||
def __getitem__(self, item):
|
||||
if item in ('json', 'xhr'):
|
||||
@@ -69,18 +80,21 @@ class Models(Base):
|
||||
|
||||
class ModelListing(Base):
|
||||
|
||||
def __init__(self, request, name):
|
||||
def __init__(self, request, name=None):
|
||||
Base.__init__(self, request, name)
|
||||
request.model_name = name
|
||||
model = self.get_model()
|
||||
if name is None:
|
||||
# request.model_class and request.model_name are already set
|
||||
model = request.model_class
|
||||
else:
|
||||
request.model_name = name
|
||||
model = self.get_model()
|
||||
if hasattr(model, '__acl__'):
|
||||
# get permissions from SA class
|
||||
self.__acl__ = model.__acl__
|
||||
|
||||
def fa_url(self, *args):
|
||||
args = args[1:]
|
||||
return self.request.route_url(self.__fa_route_name__,
|
||||
traverse='/'.join([str(a) for a in args]))
|
||||
return self._fa_url(*args[1:])
|
||||
|
||||
def __getitem__(self, item):
|
||||
if item in ('json', 'xhr'):
|
||||
self.request.format = item
|
||||
@@ -94,11 +108,10 @@ class ModelListing(Base):
|
||||
class Model(Base):
|
||||
|
||||
def fa_url(self, *args):
|
||||
args = args[2:]
|
||||
return self.request.route_url(self.__fa_route_name__,
|
||||
traverse='/'.join([str(a) for a in args]))
|
||||
return self._fa_url(*args[2:])
|
||||
|
||||
def __init__(self, request, name):
|
||||
Base.__init__(self, request, name)
|
||||
request.model_instance = request.session_factory.query(request.model_class).get(name)
|
||||
request.model_id = name
|
||||
|
||||
|
||||
@@ -4,7 +4,17 @@
|
||||
<form action="" method="POST" enctype="multipart/form-data">
|
||||
<div tal:content="structure fs.render()" />
|
||||
<input type="hidden" name="_method" value="PUT" />
|
||||
<div metal:use-macro="main.macros['buttons']">
|
||||
<div metal:define-macro="buttons">
|
||||
<p class="fa_field">
|
||||
<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all" href="#">
|
||||
<input type="submit" value="${F_('Save')}" />
|
||||
</a>
|
||||
<a class="ui-widget-header ui-widget-link ui-corner-all"
|
||||
tal:attributes="href request.fa_url(request.model_name)">
|
||||
<span class="ui-icon ui-icon-circle-arrow-w"></span>
|
||||
${F_('Cancel')}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -3,13 +3,20 @@ def bind():
|
||||
from cPickle import loads as _loads
|
||||
_lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.')
|
||||
_init_scope = _loads('cchameleon.core.utils\necontext\np1\n.')
|
||||
_attrs_4360507280 = _loads('(dp1\nVaction\np2\nV\nsVmethod\np3\nVPOST\np4\nsVenctype\np5\nVmultipart/form-data\np6\ns.')
|
||||
_attrs_4360506064 = _loads('(dp1\nVname\np2\nV_method\np3\nsVtype\np4\nVhidden\np5\nsVvalue\np6\nVPUT\np7\ns.')
|
||||
_re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.")
|
||||
_attrs_4359005584 = _loads('(dp1\n.')
|
||||
_attrs_4359005840 = _loads('(dp1\nVname\np2\nV_method\np3\nsVtype\np4\nVhidden\np5\nsVvalue\np6\nVPUT\np7\ns.')
|
||||
_attrs_4359006416 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.')
|
||||
_attrs_4359006672 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
_attrs_4359005008 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-arrow-w\np3\ns.')
|
||||
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
_attrs_4359005968 = _loads('(dp1\n.')
|
||||
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
|
||||
_attrs_4360507216 = _loads('(dp1\n.')
|
||||
_attrs_4360719504 = _loads('(dp1\n.')
|
||||
_attrs_4359006544 = _loads('(dp1\nVhref\np2\nV#\nsVclass\np3\nVui-widget-header ui-widget-link ui-widget-button ui-corner-all\np4\ns.')
|
||||
_attrs_4359005520 = _loads('(dp1\nVaction\np2\nV\nsVmethod\np3\nVPOST\np4\nsVenctype\np5\nVmultipart/form-data\np6\ns.')
|
||||
_attrs_4359006736 = _loads("(dp1\nVtype\np2\nVsubmit\np3\nsVvalue\np4\nV${F_('Save')}\np5\ns.")
|
||||
_attrs_4359005776 = _loads('(dp1\n.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
def render(econtext, rcontext=None):
|
||||
macros = econtext.get('macros')
|
||||
_translate = econtext.get('_translate')
|
||||
@@ -30,15 +37,15 @@ def bind():
|
||||
def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored):
|
||||
if _repeat:
|
||||
repeat.update(_repeat)
|
||||
attrs = _attrs_4360719504
|
||||
attrs = _attrs_4359005584
|
||||
_write(u'<div>\n ')
|
||||
attrs = _attrs_4360507280
|
||||
attrs = _attrs_4359005520
|
||||
u"''"
|
||||
_write(u'<form action="" method="POST" enctype="multipart/form-data">\n ')
|
||||
_default.value = default = ''
|
||||
u'fs.render()'
|
||||
_content = _lookup_attr(econtext['fs'], 'render')()
|
||||
attrs = _attrs_4360507216
|
||||
attrs = _attrs_4359005776
|
||||
u'_content'
|
||||
_write(u'<div>')
|
||||
_tmp1 = _content
|
||||
@@ -57,15 +64,92 @@ def bind():
|
||||
_tmp = str(_tmp)
|
||||
_write(_tmp)
|
||||
_write(u'</div>\n ')
|
||||
attrs = _attrs_4360506064
|
||||
u"main.macros['buttons']"
|
||||
attrs = _attrs_4359005840
|
||||
_write(u'<input type="hidden" name="_method" value="PUT" />\n ')
|
||||
_metal = _lookup_attr(econtext['main'], 'macros')['buttons']
|
||||
u'{}'
|
||||
_tmp = {}
|
||||
u"main.macros['buttons']"
|
||||
_metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext)
|
||||
_write(u'\n </form>\n </div>\n')
|
||||
attrs = _attrs_4359005968
|
||||
_write(u'<div>\n ')
|
||||
attrs = _attrs_4359006416
|
||||
_write(u'<p class="fa_field">\n ')
|
||||
attrs = _attrs_4359006544
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all" href="#">\n ')
|
||||
attrs = _attrs_4359006736
|
||||
'join(value("F_(\'Save\')"),)'
|
||||
_write(u'<input type="submit"')
|
||||
_tmp1 = econtext['F_']('Save')
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = u"${F_('Save')}"
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' value="' + _tmp1) + '"'))
|
||||
_write(u' />\n </a>\n ')
|
||||
attrs = _attrs_4359006672
|
||||
u'request.fa_url(request.model_name)'
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-corner-all"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'fa_url')(_lookup_attr(econtext['request'], 'model_name'))
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = None
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'>\n ')
|
||||
attrs = _attrs_4359005008
|
||||
u"F_('Cancel')"
|
||||
_write(u'<span class="ui-icon ui-icon-circle-arrow-w"></span>\n ')
|
||||
_tmp1 = econtext['F_']('Cancel')
|
||||
_tmp = _tmp1
|
||||
if (_tmp.__class__ not in (str, unicode, int, float, )):
|
||||
try:
|
||||
_tmp = _tmp.__html__
|
||||
except:
|
||||
_tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None)
|
||||
else:
|
||||
_tmp = _tmp()
|
||||
_write(_tmp)
|
||||
_tmp = None
|
||||
if (_tmp is not None):
|
||||
if not isinstance(_tmp, unicode):
|
||||
_tmp = str(_tmp)
|
||||
if ('&' in _tmp):
|
||||
if (';' in _tmp):
|
||||
_tmp = _re_amp.sub('&', _tmp)
|
||||
else:
|
||||
_tmp = _tmp.replace('&', '&')
|
||||
if ('<' in _tmp):
|
||||
_tmp = _tmp.replace('<', '<')
|
||||
if ('>' in _tmp):
|
||||
_tmp = _tmp.replace('>', '>')
|
||||
_write(_tmp)
|
||||
_write(u'\n </a>\n </p>\n </div>\n </form>\n </div>\n')
|
||||
u"{'main': _callback_main}"
|
||||
_tmp = {'main': _callback_main, }
|
||||
u"main.macros['master']"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<table class="layout-grid" tal:content="structure fs.render()" />
|
||||
<p>
|
||||
<a class="ui-widget-header ui-widget-link ui-corner-all"
|
||||
tal:attributes="href request.route_url(request.route_name, traverse='%s/new' % request.model_name)">
|
||||
tal:attributes="href request.fa_url(request.model_name, 'new')">
|
||||
<span class="ui-icon ui-icon-circle-plus"></span>
|
||||
${F_('New')} ${model_name}
|
||||
</a>
|
||||
|
||||
@@ -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_4360530640 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-plus\np3\ns.')
|
||||
_attrs_4360530960 = _loads('(dp1\n.')
|
||||
_attrs_4360531152 = _loads('(dp1\nVclass\np2\nVui-pager\np3\ns.')
|
||||
_attrs_4360531728 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
_attrs_4359083472 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
_attrs_4359083344 = _loads('(dp1\n.')
|
||||
_attrs_4359083216 = _loads('(dp1\nVclass\np2\nVui-pager\np3\ns.')
|
||||
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
|
||||
_attrs_4360531344 = _loads('(dp1\n.')
|
||||
_attrs_4359083600 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-plus\np3\ns.')
|
||||
_attrs_4359083088 = _loads('(dp1\n.')
|
||||
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
_attrs_4360531408 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.')
|
||||
_attrs_4359083280 = _loads('(dp1\nVclass\np2\nVlayout-grid\np3\ns.')
|
||||
def render(econtext, rcontext=None):
|
||||
macros = econtext.get('macros')
|
||||
_translate = econtext.get('_translate')
|
||||
@@ -33,13 +33,13 @@ def bind():
|
||||
def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored):
|
||||
if _repeat:
|
||||
repeat.update(_repeat)
|
||||
attrs = _attrs_4360530960
|
||||
attrs = _attrs_4359083088
|
||||
u"''"
|
||||
_write(u'<div>\n ')
|
||||
_default.value = default = ''
|
||||
u'pager'
|
||||
_content = econtext['pager']
|
||||
attrs = _attrs_4360531152
|
||||
attrs = _attrs_4359083216
|
||||
u'_content'
|
||||
_write(u'<div class="ui-pager">')
|
||||
_tmp1 = _content
|
||||
@@ -62,7 +62,7 @@ def bind():
|
||||
_default.value = default = ''
|
||||
u'fs.render()'
|
||||
_content = _lookup_attr(econtext['fs'], 'render')()
|
||||
attrs = _attrs_4360531408
|
||||
attrs = _attrs_4359083280
|
||||
u'_content'
|
||||
_write(u'<table class="layout-grid">')
|
||||
_tmp1 = _content
|
||||
@@ -81,12 +81,12 @@ def bind():
|
||||
_tmp = str(_tmp)
|
||||
_write(_tmp)
|
||||
_write(u'</table>\n ')
|
||||
attrs = _attrs_4360531344
|
||||
attrs = _attrs_4359083344
|
||||
_write(u'<p>\n ')
|
||||
attrs = _attrs_4360531728
|
||||
u"request.route_url(request.route_name, traverse='%s/new' % request.model_name)"
|
||||
attrs = _attrs_4359083472
|
||||
u"request.fa_url(request.model_name, 'new')"
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-corner-all"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'route_url')(_lookup_attr(econtext['request'], 'route_name'), traverse=('%s/new' % _lookup_attr(econtext['request'], 'model_name')))
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'fa_url')(_lookup_attr(econtext['request'], 'model_name'), 'new')
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = None
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
@@ -108,7 +108,7 @@ def bind():
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'>\n ')
|
||||
attrs = _attrs_4360530640
|
||||
attrs = _attrs_4359083600
|
||||
u"F_('New')"
|
||||
_write(u'<span class="ui-icon ui-icon-circle-plus"></span>\n ')
|
||||
_tmp1 = econtext['F_']('New')
|
||||
|
||||
@@ -20,15 +20,3 @@
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<div metal:define-macro="buttons">
|
||||
<p class="fa_field">
|
||||
<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all" href="#">
|
||||
<input type="submit" value="${F_('Save')}" />
|
||||
</a>
|
||||
<a class="ui-widget-header ui-widget-link ui-corner-all"
|
||||
tal:attributes="href request.route_url(request.route_name, traverse=request.model_name)">
|
||||
<span class="ui-icon ui-icon-circle-arrow-w"></span>
|
||||
${F_('Cancel')}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
registry = dict(version=0)
|
||||
def bind():
|
||||
from cPickle import loads as _loads
|
||||
_attrs_4356111248 = _loads('(dp1\nVrel\np2\nVstylesheet\np3\ns.')
|
||||
_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_4356112272 = _loads('(dp1\n.')
|
||||
_attrs_4356111632 = _loads('(dp1\nVid\np2\nVheader\np3\nsVclass\np4\nVui-widget-header ui-corner-all\np5\ns.')
|
||||
_attrs_4356108816 = _loads('(dp1\n.')
|
||||
_attrs_4356111440 = _loads('(dp1\n.')
|
||||
_attrs_4358968400 = _loads('(dp1\n.')
|
||||
_attrs_4358849552 = _loads('(dp1\n.')
|
||||
_attrs_4358967760 = _loads('(dp1\nVid\np2\nVheader\np3\nsVclass\np4\nVui-widget-header ui-corner-all\np5\ns.')
|
||||
_attrs_4358720592 = _loads('(dp1\nVrel\np2\nVstylesheet\np3\ns.')
|
||||
_attrs_4358967504 = _loads('(dp1\nVid\np2\nVcontent\np3\nsVclass\np4\nVui-admin ui-widget\np5\ns.')
|
||||
_attrs_4358967888 = _loads('(dp1\nVclass\np2\nVbreadcrumb\np3\ns.')
|
||||
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
|
||||
_attrs_4356108496 = _loads('(dp1\n.')
|
||||
_attrs_4356112144 = _loads('(dp1\nVclass\np2\nVbreadcrumb\np3\ns.')
|
||||
_attrs_4356111184 = _loads('(dp1\n.')
|
||||
_attrs_4356111888 = _loads('(dp1\nVid\np2\nVcontent\np3\nsVclass\np4\nVui-admin ui-widget\np5\ns.')
|
||||
_attrs_4358968272 = _loads('(dp1\n.')
|
||||
_attrs_4358721104 = _loads('(dp1\n.')
|
||||
_attrs_4358721040 = _loads('(dp1\n.')
|
||||
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
|
||||
_attrs_4356111120 = _loads('(dp1\n.')
|
||||
_attrs_4356112080 = _loads('(dp1\n.')
|
||||
_attrs_4358721232 = _loads('(dp1\n.')
|
||||
_attrs_4358967696 = _loads('(dp1\n.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
_attrs_4356111056 = _loads('(dp1\n.')
|
||||
_attrs_4358967952 = _loads('(dp1\n.')
|
||||
def render(econtext, rcontext=None):
|
||||
macros = econtext.get('macros')
|
||||
_translate = econtext.get('_translate')
|
||||
@@ -34,15 +34,15 @@ def bind():
|
||||
default = None
|
||||
u'None'
|
||||
_domain = None
|
||||
attrs = _attrs_4356111440
|
||||
attrs = _attrs_4358849552
|
||||
_write(u'<html>\n ')
|
||||
attrs = _attrs_4356111056
|
||||
attrs = _attrs_4358721040
|
||||
u"''"
|
||||
_write(u'<head>\n ')
|
||||
_default.value = default = ''
|
||||
u"request.model_name or 'root'"
|
||||
_content = (_lookup_attr(econtext['request'], 'model_name') or 'root')
|
||||
attrs = _attrs_4356111184
|
||||
attrs = _attrs_4358721104
|
||||
u'_content'
|
||||
_write(u'<title>')
|
||||
_tmp1 = _content
|
||||
@@ -70,7 +70,7 @@ def bind():
|
||||
_tmp = _tmp.replace('>', '>')
|
||||
_write(_tmp)
|
||||
_write(u'</title>\n ')
|
||||
attrs = _attrs_4356111248
|
||||
attrs = _attrs_4358720592
|
||||
u"request.static_url('pyramid_formalchemy:static/admin.css')"
|
||||
_write(u'<link rel="stylesheet"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'static_url')('pyramid_formalchemy:static/admin.css')
|
||||
@@ -95,13 +95,13 @@ def bind():
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'></link>\n </head>\n ')
|
||||
attrs = _attrs_4356111120
|
||||
attrs = _attrs_4358721232
|
||||
_write(u'<body>\n ')
|
||||
attrs = _attrs_4356111888
|
||||
attrs = _attrs_4358967504
|
||||
_write(u'<div id="content" class="ui-admin ui-widget">\n ')
|
||||
attrs = _attrs_4356111632
|
||||
attrs = _attrs_4358967760
|
||||
_write(u'<h1 id="header" class="ui-widget-header ui-corner-all">\n ')
|
||||
attrs = _attrs_4356112144
|
||||
attrs = _attrs_4358967888
|
||||
u'breadcrumb'
|
||||
_write(u'<div class="breadcrumb">\n ')
|
||||
_tmp1 = econtext['breadcrumb']
|
||||
@@ -114,7 +114,7 @@ def bind():
|
||||
_default.value = default = ''
|
||||
u'item[1]'
|
||||
_content = item[1]
|
||||
attrs = _attrs_4356108496
|
||||
attrs = _attrs_4358968400
|
||||
u'item[0]'
|
||||
_write(u'<a')
|
||||
_tmp3 = item[0]
|
||||
@@ -169,7 +169,7 @@ def bind():
|
||||
_tmp3 = not _lookup_attr(repeat.item, 'end')
|
||||
if _tmp3:
|
||||
pass
|
||||
attrs = _attrs_4356108816
|
||||
attrs = _attrs_4358968272
|
||||
_write(u'<span>/</span>')
|
||||
_write(u'\n ')
|
||||
if (_tmp2 == 0):
|
||||
@@ -180,7 +180,7 @@ def bind():
|
||||
_default.value = default = ''
|
||||
u"request.model_name or 'root'"
|
||||
_content = (_lookup_attr(econtext['request'], 'model_name') or 'root')
|
||||
attrs = _attrs_4356112272
|
||||
attrs = _attrs_4358967952
|
||||
u'_content'
|
||||
_write(u'<div>')
|
||||
_tmp1 = _content
|
||||
@@ -240,7 +240,7 @@ def bind():
|
||||
_write(_tmp)
|
||||
else:
|
||||
pass
|
||||
attrs = _attrs_4356112080
|
||||
attrs = _attrs_4358967696
|
||||
_write(u'<div>\n </div>')
|
||||
_write(u'\n </div>\n </body>\n</html>')
|
||||
return
|
||||
@@ -248,121 +248,3 @@ def bind():
|
||||
|
||||
__filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/master.pt'
|
||||
registry[('master', False, '1488bdb950901f8f258549439ef6661a49aae984')] = bind()
|
||||
def bind():
|
||||
from cPickle import loads as _loads
|
||||
_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_4356061584 = _loads("(dp1\nVtype\np2\nVsubmit\np3\nsVvalue\np4\nV${F_('Save')}\np5\ns.")
|
||||
_attrs_4356061712 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-arrow-w\np3\ns.')
|
||||
_attrs_4356061456 = _loads('(dp1\nVhref\np2\nV#\nsVclass\np3\nVui-widget-header ui-widget-link ui-widget-button ui-corner-all\np4\ns.')
|
||||
_attrs_4356059984 = _loads('(dp1\n.')
|
||||
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
|
||||
_attrs_4356060496 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.')
|
||||
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
_attrs_4356062352 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
def render(econtext, rcontext=None):
|
||||
macros = econtext.get('macros')
|
||||
_translate = econtext.get('_translate')
|
||||
_slots = econtext.get('_slots')
|
||||
target_language = econtext.get('target_language')
|
||||
u"%(scope)s['%(out)s'], %(scope)s['%(write)s']"
|
||||
(_out, _write, ) = (econtext['_out'], econtext['_write'], )
|
||||
u'_init_tal()'
|
||||
(_attributes, repeat, ) = _init_tal()
|
||||
u'_init_default()'
|
||||
_default = _init_default()
|
||||
u'None'
|
||||
default = None
|
||||
u'None'
|
||||
_domain = None
|
||||
attrs = _attrs_4356059984
|
||||
_write(u'<div>\n ')
|
||||
attrs = _attrs_4356060496
|
||||
_write(u'<p class="fa_field">\n ')
|
||||
attrs = _attrs_4356061456
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all" href="#">\n ')
|
||||
attrs = _attrs_4356061584
|
||||
'join(value("F_(\'Save\')"),)'
|
||||
_write(u'<input type="submit"')
|
||||
_tmp1 = econtext['F_']('Save')
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = u"${F_('Save')}"
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' value="' + _tmp1) + '"'))
|
||||
_write(u' />\n </a>\n ')
|
||||
attrs = _attrs_4356062352
|
||||
u'request.route_url(request.route_name, traverse=request.model_name)'
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-corner-all"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'route_url')(_lookup_attr(econtext['request'], 'route_name'), traverse=_lookup_attr(econtext['request'], 'model_name'))
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = None
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'>\n ')
|
||||
attrs = _attrs_4356061712
|
||||
u"F_('Cancel')"
|
||||
_write(u'<span class="ui-icon ui-icon-circle-arrow-w"></span>\n ')
|
||||
_tmp1 = econtext['F_']('Cancel')
|
||||
_tmp = _tmp1
|
||||
if (_tmp.__class__ not in (str, unicode, int, float, )):
|
||||
try:
|
||||
_tmp = _tmp.__html__
|
||||
except:
|
||||
_tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None)
|
||||
else:
|
||||
_tmp = _tmp()
|
||||
_write(_tmp)
|
||||
_tmp = None
|
||||
if (_tmp is not None):
|
||||
if not isinstance(_tmp, unicode):
|
||||
_tmp = str(_tmp)
|
||||
if ('&' in _tmp):
|
||||
if (';' in _tmp):
|
||||
_tmp = _re_amp.sub('&', _tmp)
|
||||
else:
|
||||
_tmp = _tmp.replace('&', '&')
|
||||
if ('<' in _tmp):
|
||||
_tmp = _tmp.replace('<', '<')
|
||||
if ('>' in _tmp):
|
||||
_tmp = _tmp.replace('>', '>')
|
||||
_write(_tmp)
|
||||
_write(u'\n </a>\n </p>\n</div>')
|
||||
return
|
||||
return render
|
||||
|
||||
__filename__ = '/Users/gawel/py/formalchemy_project/pyramid_formalchemy/pyramid_formalchemy/templates/admin/master.pt'
|
||||
registry[('buttons', False, '1488bdb950901f8f258549439ef6661a49aae984')] = bind()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<body>
|
||||
<div metal:fill-slot="main">
|
||||
<form method="POST" enctype="multipart/form-data"
|
||||
tal:attributes="action request.route_url(request.route_name, traverse=request.model_name)"
|
||||
tal:attributes="action request.fa_url(request.model_name)"
|
||||
>
|
||||
<div tal:content="structure fs.render()" />
|
||||
<p class="fa_field">
|
||||
@@ -10,7 +10,7 @@
|
||||
<input type="submit" value="${F_('Save')}" />
|
||||
</a>
|
||||
<a class="ui-widget-header ui-widget-link ui-corner-all"
|
||||
tal:attributes="href request.route_url(request.route_name, traverse=request.model_name)">
|
||||
tal:attributes="href request.fa_url(request.model_name)">
|
||||
<span class="ui-icon ui-icon-circle-arrow-w"></span>
|
||||
${F_('Cancel')}
|
||||
</a>
|
||||
|
||||
@@ -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_4360526096 = _loads('(dp1\n.')
|
||||
_attrs_4358666896 = _loads("(dp1\nVtype\np2\nVsubmit\np3\nsVvalue\np4\nV${F_('Save')}\np5\ns.")
|
||||
_attrs_4358666576 = _loads('(dp1\n.')
|
||||
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
|
||||
_attrs_4360527440 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
_attrs_4360525712 = _loads('(dp1\nVmethod\np2\nVPOST\np3\nsVenctype\np4\nVmultipart/form-data\np5\ns.')
|
||||
_attrs_4358666640 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.')
|
||||
_attrs_4358666448 = _loads('(dp1\nVmethod\np2\nVPOST\np3\nsVenctype\np4\nVmultipart/form-data\np5\ns.')
|
||||
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
|
||||
_attrs_4360526736 = _loads('(dp1\nVhref\np2\nV#\nsVclass\np3\nVui-widget-header ui-widget-link ui-widget-button ui-corner-all\np4\ns.')
|
||||
_attrs_4360525200 = _loads('(dp1\n.')
|
||||
_attrs_4360527632 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-arrow-w\np3\ns.')
|
||||
_attrs_4360527120 = _loads("(dp1\nVtype\np2\nVsubmit\np3\nsVvalue\np4\nV${F_('Save')}\np5\ns.")
|
||||
_attrs_4358667024 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-arrow-w\np3\ns.')
|
||||
_attrs_4358666320 = _loads('(dp1\n.')
|
||||
_attrs_4358666832 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
_attrs_4358666768 = _loads('(dp1\nVhref\np2\nV#\nsVclass\np3\nVui-widget-header ui-widget-link ui-widget-button ui-corner-all\np4\ns.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
_attrs_4360526224 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.')
|
||||
def render(econtext, rcontext=None):
|
||||
macros = econtext.get('macros')
|
||||
_translate = econtext.get('_translate')
|
||||
@@ -35,12 +35,12 @@ def bind():
|
||||
def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored):
|
||||
if _repeat:
|
||||
repeat.update(_repeat)
|
||||
attrs = _attrs_4360525200
|
||||
attrs = _attrs_4358666320
|
||||
_write(u'<div>\n ')
|
||||
attrs = _attrs_4360525712
|
||||
u'request.route_url(request.route_name, traverse=request.model_name)'
|
||||
attrs = _attrs_4358666448
|
||||
u'request.fa_url(request.model_name)'
|
||||
_write(u'<form method="POST" enctype="multipart/form-data"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'route_url')(_lookup_attr(econtext['request'], 'route_name'), traverse=_lookup_attr(econtext['request'], 'model_name'))
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'fa_url')(_lookup_attr(econtext['request'], 'model_name'))
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = None
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
@@ -66,7 +66,7 @@ def bind():
|
||||
_default.value = default = ''
|
||||
u'fs.render()'
|
||||
_content = _lookup_attr(econtext['fs'], 'render')()
|
||||
attrs = _attrs_4360526096
|
||||
attrs = _attrs_4358666576
|
||||
u'_content'
|
||||
_write(u'<div>')
|
||||
_tmp1 = _content
|
||||
@@ -85,11 +85,11 @@ def bind():
|
||||
_tmp = str(_tmp)
|
||||
_write(_tmp)
|
||||
_write(u'</div>\n ')
|
||||
attrs = _attrs_4360526224
|
||||
attrs = _attrs_4358666640
|
||||
_write(u'<p class="fa_field">\n ')
|
||||
attrs = _attrs_4360526736
|
||||
attrs = _attrs_4358666768
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all" href="#">\n ')
|
||||
attrs = _attrs_4360527120
|
||||
attrs = _attrs_4358666896
|
||||
'join(value("F_(\'Save\')"),)'
|
||||
_write(u'<input type="submit"')
|
||||
_tmp1 = econtext['F_']('Save')
|
||||
@@ -114,10 +114,10 @@ def bind():
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' value="' + _tmp1) + '"'))
|
||||
_write(u' />\n </a>\n ')
|
||||
attrs = _attrs_4360527440
|
||||
u'request.route_url(request.route_name, traverse=request.model_name)'
|
||||
attrs = _attrs_4358666832
|
||||
u'request.fa_url(request.model_name)'
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-corner-all"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'route_url')(_lookup_attr(econtext['request'], 'route_name'), traverse=_lookup_attr(econtext['request'], 'model_name'))
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'fa_url')(_lookup_attr(econtext['request'], 'model_name'))
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = None
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
@@ -139,7 +139,7 @@ def bind():
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'>\n ')
|
||||
attrs = _attrs_4360527632
|
||||
attrs = _attrs_4358667024
|
||||
u"F_('Cancel')"
|
||||
_write(u'<span class="ui-icon ui-icon-circle-arrow-w"></span>\n ')
|
||||
_tmp1 = econtext['F_']('Cancel')
|
||||
|
||||
@@ -2,7 +2,18 @@
|
||||
<body>
|
||||
<div metal:fill-slot="main">
|
||||
<div tal:content="structure fs.render()" />
|
||||
<div metal:use-macro="main.macros['buttons']">
|
||||
<div>
|
||||
<p class="fa_field">
|
||||
<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all" href="#"
|
||||
tal:attributes="href request.fa_url(request.model_name, request.model_id, 'edit')">
|
||||
<input type="submit" value="${F_('Edit')}" />
|
||||
</a>
|
||||
<a class="ui-widget-header ui-widget-link ui-corner-all"
|
||||
tal:attributes="href request.fa_url(request.model_name)">
|
||||
<span class="ui-icon ui-icon-circle-arrow-w"></span>
|
||||
${F_('Back')}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -3,10 +3,17 @@ def bind():
|
||||
from cPickle import loads as _loads
|
||||
_lookup_attr = _loads('cchameleon.core.codegen\nlookup_attr\np1\n.')
|
||||
_init_scope = _loads('cchameleon.core.utils\necontext\np1\n.')
|
||||
_attrs_4360545744 = _loads('(dp1\n.')
|
||||
_re_amp = _loads("cre\n_compile\np1\n(S'&(?!([A-Za-z]+|#[0-9]+);)'\np2\nI0\ntRp3\n.")
|
||||
_attrs_4358950864 = _loads("(dp1\nVtype\np2\nVsubmit\np3\nsVvalue\np4\nV${F_('Edit')}\np5\ns.")
|
||||
_attrs_4358949968 = _loads('(dp1\n.')
|
||||
_attrs_4358950480 = _loads('(dp1\nVclass\np2\nVfa_field\np3\ns.')
|
||||
_attrs_4358950672 = _loads('(dp1\nVhref\np2\nV#\nsVclass\np3\nVui-widget-header ui-widget-link ui-widget-button ui-corner-all\np4\ns.')
|
||||
_init_stream = _loads('cchameleon.core.generation\ninitialize_stream\np1\n.')
|
||||
_attrs_4358950160 = _loads('(dp1\n.')
|
||||
_init_default = _loads('cchameleon.core.generation\ninitialize_default\np1\n.')
|
||||
_attrs_4360546576 = _loads('(dp1\n.')
|
||||
_attrs_4358950288 = _loads('(dp1\n.')
|
||||
_attrs_4358988048 = _loads('(dp1\nVclass\np2\nVui-icon ui-icon-circle-arrow-w\np3\ns.')
|
||||
_attrs_4358987856 = _loads('(dp1\nVclass\np2\nVui-widget-header ui-widget-link ui-corner-all\np3\ns.')
|
||||
_init_tal = _loads('cchameleon.core.generation\ninitialize_tal\np1\n.')
|
||||
def render(econtext, rcontext=None):
|
||||
macros = econtext.get('macros')
|
||||
@@ -28,13 +35,13 @@ def bind():
|
||||
def _callback_main(econtext, _repeat, _out=_out, _write=_write, _domain=_domain, **_ignored):
|
||||
if _repeat:
|
||||
repeat.update(_repeat)
|
||||
attrs = _attrs_4360545744
|
||||
attrs = _attrs_4358949968
|
||||
u"''"
|
||||
_write(u'<div>\n ')
|
||||
_default.value = default = ''
|
||||
u'fs.render()'
|
||||
_content = _lookup_attr(econtext['fs'], 'render')()
|
||||
attrs = _attrs_4360546576
|
||||
attrs = _attrs_4358950160
|
||||
u'_content'
|
||||
_write(u'<div>')
|
||||
_tmp1 = _content
|
||||
@@ -52,14 +59,114 @@ def bind():
|
||||
if not isinstance(_tmp, unicode):
|
||||
_tmp = str(_tmp)
|
||||
_write(_tmp)
|
||||
u"main.macros['buttons']"
|
||||
_write(u'</div>\n ')
|
||||
_metal = _lookup_attr(econtext['main'], 'macros')['buttons']
|
||||
u'{}'
|
||||
_tmp = {}
|
||||
u"main.macros['buttons']"
|
||||
_metal.render(_tmp, _out=_out, _write=_write, _domain=_domain, econtext=econtext)
|
||||
_write(u'\n </div>\n')
|
||||
attrs = _attrs_4358950288
|
||||
_write(u'<div>\n ')
|
||||
attrs = _attrs_4358950480
|
||||
_write(u'<p class="fa_field">\n ')
|
||||
attrs = _attrs_4358950672
|
||||
u"request.fa_url(request.model_name, request.model_id, 'edit')"
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-widget-button ui-corner-all"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'fa_url')(_lookup_attr(econtext['request'], 'model_name'), _lookup_attr(econtext['request'], 'model_id'), 'edit')
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = u'#'
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'>\n ')
|
||||
attrs = _attrs_4358950864
|
||||
'join(value("F_(\'Edit\')"),)'
|
||||
_write(u'<input type="submit"')
|
||||
_tmp1 = econtext['F_']('Edit')
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = u"${F_('Edit')}"
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' value="' + _tmp1) + '"'))
|
||||
_write(u' />\n </a>\n ')
|
||||
attrs = _attrs_4358987856
|
||||
u'request.fa_url(request.model_name)'
|
||||
_write(u'<a class="ui-widget-header ui-widget-link ui-corner-all"')
|
||||
_tmp1 = _lookup_attr(econtext['request'], 'fa_url')(_lookup_attr(econtext['request'], 'model_name'))
|
||||
if (_tmp1 is _default):
|
||||
_tmp1 = None
|
||||
if ((_tmp1 is not None) and (_tmp1 is not False)):
|
||||
if (_tmp1.__class__ not in (str, unicode, int, float, )):
|
||||
_tmp1 = unicode(_translate(_tmp1, domain=_domain, mapping=None, target_language=target_language, default=None))
|
||||
else:
|
||||
if not isinstance(_tmp1, unicode):
|
||||
_tmp1 = str(_tmp1)
|
||||
if ('&' in _tmp1):
|
||||
if (';' in _tmp1):
|
||||
_tmp1 = _re_amp.sub('&', _tmp1)
|
||||
else:
|
||||
_tmp1 = _tmp1.replace('&', '&')
|
||||
if ('<' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('<', '<')
|
||||
if ('>' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('>', '>')
|
||||
if ('"' in _tmp1):
|
||||
_tmp1 = _tmp1.replace('"', '"')
|
||||
_write(((' href="' + _tmp1) + '"'))
|
||||
_write(u'>\n ')
|
||||
attrs = _attrs_4358988048
|
||||
u"F_('Back')"
|
||||
_write(u'<span class="ui-icon ui-icon-circle-arrow-w"></span>\n ')
|
||||
_tmp1 = econtext['F_']('Back')
|
||||
_tmp = _tmp1
|
||||
if (_tmp.__class__ not in (str, unicode, int, float, )):
|
||||
try:
|
||||
_tmp = _tmp.__html__
|
||||
except:
|
||||
_tmp = _translate(_tmp, domain=_domain, mapping=None, target_language=target_language, default=None)
|
||||
else:
|
||||
_tmp = _tmp()
|
||||
_write(_tmp)
|
||||
_tmp = None
|
||||
if (_tmp is not None):
|
||||
if not isinstance(_tmp, unicode):
|
||||
_tmp = str(_tmp)
|
||||
if ('&' in _tmp):
|
||||
if (';' in _tmp):
|
||||
_tmp = _re_amp.sub('&', _tmp)
|
||||
else:
|
||||
_tmp = _tmp.replace('&', '&')
|
||||
if ('<' in _tmp):
|
||||
_tmp = _tmp.replace('<', '<')
|
||||
if ('>' in _tmp):
|
||||
_tmp = _tmp.replace('>', '>')
|
||||
_write(_tmp)
|
||||
_write(u'\n </a>\n </p>\n </div>\n </div>\n')
|
||||
u"{'main': _callback_main}"
|
||||
_tmp = {'main': _callback_main, }
|
||||
u"main.macros['master']"
|
||||
|
||||
@@ -59,18 +59,18 @@ class ModelView(object):
|
||||
|
||||
def Session(self):
|
||||
"""return a Session object. You **must** override this."""
|
||||
return self.request.session_factory()
|
||||
return self.request.session_factory
|
||||
|
||||
def models(self, **kwargs):
|
||||
"""Models index page"""
|
||||
request = self.request
|
||||
models = {}
|
||||
if isinstance(request.model, list):
|
||||
for model in request.model:
|
||||
if isinstance(request.models, list):
|
||||
for model in request.models:
|
||||
key = model.__name__
|
||||
models[key] = request.fa_url(key, request.format)
|
||||
else:
|
||||
for key, obj in request.model.__dict__.iteritems():
|
||||
for key, obj in request.models.__dict__.iteritems():
|
||||
if not key.startswith('_'):
|
||||
if Document is not None:
|
||||
try:
|
||||
@@ -195,37 +195,16 @@ class ModelView(object):
|
||||
collection = options.pop('collection')
|
||||
return Page(collection, **options)
|
||||
|
||||
def get(self, id=None):
|
||||
"""return correct record for ``id`` or a new instance.
|
||||
|
||||
Default is::
|
||||
|
||||
S = self.Session()
|
||||
model = self.context.get_model()
|
||||
if id:
|
||||
model = S.query(model).get(id)
|
||||
else:
|
||||
model = model()
|
||||
raise NotFound()
|
||||
|
||||
"""
|
||||
S = self.Session()
|
||||
model = self.context.get_model()
|
||||
if id:
|
||||
model = S.query(model).get(id)
|
||||
if model:
|
||||
return model
|
||||
raise NotFound()
|
||||
|
||||
def get_fieldset(self, id=None):
|
||||
"""return a ``FieldSet`` object bound to the correct record for ``id``.
|
||||
"""
|
||||
request = self.request
|
||||
model = id and request.model_instance or request.model_class
|
||||
if request.forms and hasattr(request.forms, self.model_name):
|
||||
fs = getattr(request.forms, self.model_name)
|
||||
fs.engine = fs.engine or self.engine
|
||||
return id and fs.bind(self.get(id)) or fs
|
||||
fs = self.FieldSet(self.get(id))
|
||||
return id and fs.bind(model) or fs
|
||||
fs = self.FieldSet(model)
|
||||
fs.engine = fs.engine or self.engine
|
||||
return fs
|
||||
|
||||
@@ -338,8 +317,7 @@ class ModelView(object):
|
||||
S.flush()
|
||||
if request.format == 'html':
|
||||
if request.is_xhr:
|
||||
response.content_type = 'text/plain'
|
||||
return ''
|
||||
return Response(content_type='text/plain')
|
||||
next = request.POST.get('next') or request.fa_url(request.model_name)
|
||||
return exc.HTTPFound(
|
||||
location=next)
|
||||
@@ -351,8 +329,7 @@ class ModelView(object):
|
||||
def delete(self, **kwargs):
|
||||
"""REST api"""
|
||||
request = self.request
|
||||
id = request.model_id
|
||||
record = self.get(id)
|
||||
record = request.model_instance
|
||||
if record:
|
||||
S = self.Session()
|
||||
S.delete(record)
|
||||
@@ -362,7 +339,7 @@ class ModelView(object):
|
||||
response.content_type = 'text/plain'
|
||||
return response
|
||||
return exc.HTTPFound(location=request.fa_url(request.model_name))
|
||||
return self.render(id=id)
|
||||
return self.render(id=request.model_id)
|
||||
|
||||
def show(self):
|
||||
"""REST api"""
|
||||
|
||||
@@ -6,7 +6,7 @@ debug_notfound = false
|
||||
debug_routematch = false
|
||||
debug_templates = true
|
||||
default_locale_name = en
|
||||
sqlalchemy.url = sqlite://
|
||||
sqlalchemy.url = %(db)s
|
||||
|
||||
[pipeline:main]
|
||||
pipeline =
|
||||
|
||||
@@ -15,8 +15,13 @@ def main(global_config, **settings):
|
||||
|
||||
# pyramid_formalchemy's configuration
|
||||
config.include('pyramid_formalchemy')
|
||||
|
||||
# register an admin UI
|
||||
config.formalchemy_admin('admin', package='pyramidapp')
|
||||
|
||||
# register an admin UI for a single model
|
||||
config.formalchemy_model('foo', package='pyramidapp', model='pyramidapp.models.Foo')
|
||||
|
||||
return config.make_wsgi_app()
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,14 @@ def main(global_config, **settings):
|
||||
# pyramid_formalchemy's configuration
|
||||
config.include('pyramid_formalchemy')
|
||||
config.include('fa.jquery')
|
||||
config.formalchemy_admin('admin', package='pyramidapp', view='fa.jquery.pyramid.ModelView')
|
||||
|
||||
# register an admin UI
|
||||
config.formalchemy_admin('/admin', package='pyramidapp', view='fa.jquery.pyramid.ModelView')
|
||||
|
||||
# register an admin UI for a single model
|
||||
config.formalchemy_model('/foo', package='pyramidapp',
|
||||
view='fa.jquery.pyramid.ModelView',
|
||||
model='pyramidapp.models.Foo')
|
||||
|
||||
return config.make_wsgi_app()
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import unittest
|
||||
import unittest2 as unittest
|
||||
from pyramid.config import Configurator
|
||||
from pyramid import testing
|
||||
from sqlalchemy.orm import scoped_session
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from zope.sqlalchemy import ZopeTransactionExtension
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from webtest import TestApp
|
||||
from pyramidapp import main
|
||||
from pyramidapp import models
|
||||
from paste.deploy import loadapp
|
||||
|
||||
dirname = os.path.abspath(__file__)
|
||||
@@ -17,18 +24,15 @@ class Test_1_UI(unittest.TestCase):
|
||||
extra_environ = {}
|
||||
|
||||
def setUp(self):
|
||||
app = loadapp('config:%s' % self.config)
|
||||
app = loadapp('config:%s' % self.config, global_conf={'db':'sqlite://'})
|
||||
self.app = TestApp(app, extra_environ=self.extra_environ)
|
||||
self.config = Configurator(autocommit=True)
|
||||
self.config.begin()
|
||||
|
||||
def tearDown(self):
|
||||
self.config.end()
|
||||
|
||||
def test_index(self):
|
||||
resp = self.app.get('/')
|
||||
|
||||
def test_crud(self):
|
||||
def test_1_crud(self):
|
||||
# index
|
||||
resp = self.app.get('/admin')
|
||||
self.assertEqual(resp.status_int, 302)
|
||||
@@ -73,7 +77,51 @@ class Test_1_UI(unittest.TestCase):
|
||||
|
||||
assert 'new value' not in resp, resp
|
||||
|
||||
def test_json(self):
|
||||
def test_2_model(self):
|
||||
# index
|
||||
resp = self.app.get('/foo')
|
||||
self.assertEqual(resp.status_int, 302)
|
||||
assert '/' in resp.location, resp
|
||||
|
||||
## Simple model
|
||||
resp = self.app.get('/foo/')
|
||||
|
||||
# add page
|
||||
resp.mustcontain('/foo/new')
|
||||
resp = resp.click('New Foo')
|
||||
resp.mustcontain('/foo')
|
||||
form = resp.forms[0]
|
||||
form['Foo--bar'] = 'value'
|
||||
resp = form.submit()
|
||||
assert resp.headers['location'] == 'http://localhost/foo/', resp
|
||||
|
||||
# model index
|
||||
resp = resp.follow()
|
||||
resp.mustcontain('<td>value</td>')
|
||||
form = resp.forms[0]
|
||||
resp = form.submit()
|
||||
|
||||
# edit page
|
||||
form = resp.forms[0]
|
||||
form['Foo-1-bar'] = 'new value'
|
||||
#form['_method'] = 'PUT'
|
||||
resp = form.submit()
|
||||
resp = resp.follow()
|
||||
|
||||
# model index
|
||||
resp.mustcontain('<td>new value</td>')
|
||||
|
||||
# delete
|
||||
resp = self.app.get('/foo/')
|
||||
resp.mustcontain('<td>new value</td>')
|
||||
resp = resp.forms[1].submit()
|
||||
resp = resp.follow()
|
||||
|
||||
assert 'new value' not in resp, resp
|
||||
|
||||
|
||||
|
||||
def test_3_json(self):
|
||||
# index
|
||||
response = self.app.get('/admin/json')
|
||||
response.mustcontain('{"models": {', '"Foo": "http://localhost/admin/Foo/json"')
|
||||
@@ -100,6 +148,7 @@ class Test_1_UI(unittest.TestCase):
|
||||
|
||||
# delete
|
||||
response = self.app.delete(str(data['item_url']))
|
||||
self.assert_(response.json['id'] > 0)
|
||||
|
||||
class Test_2_Security(Test_1_UI):
|
||||
|
||||
@@ -122,11 +171,14 @@ class Test_2_Security(Test_1_UI):
|
||||
resp = self.app.get('/admin/Bar', extra_environ={'REMOTE_USER': 'bar_manager'})
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
def test_2_model(self):
|
||||
pass
|
||||
|
||||
class Test_3_JQuery(Test_1_UI):
|
||||
|
||||
config = os.path.join(dirname, 'jquery.ini')
|
||||
|
||||
def test_crud(self):
|
||||
def test_1_crud(self):
|
||||
# index
|
||||
resp = self.app.get('/admin/')
|
||||
resp.mustcontain('/admin/Foo')
|
||||
@@ -161,3 +213,5 @@ class Test_3_JQuery(Test_1_UI):
|
||||
resp = self.app.get('/admin/Foo')
|
||||
resp.mustcontain('jQuery')
|
||||
|
||||
def test_2_model(self):
|
||||
pass
|
||||
|
||||
@@ -6,7 +6,7 @@ debug_notfound = false
|
||||
debug_routematch = false
|
||||
debug_templates = true
|
||||
default_locale_name = en
|
||||
sqlalchemy.url = sqlite://
|
||||
sqlalchemy.url = %(db)s
|
||||
|
||||
[pipeline:main]
|
||||
pipeline =
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ debug_notfound = false
|
||||
debug_routematch = false
|
||||
debug_templates = true
|
||||
default_locale_name = en
|
||||
sqlalchemy.url = sqlite://
|
||||
sqlalchemy.url = %(db)s
|
||||
|
||||
[pipeline:main]
|
||||
pipeline =
|
||||
|
||||
Reference in New Issue
Block a user