Apr 15, 2011
Pyramid CRUD vol.2
In my previous post I was trying to see what could be the benefit for Pylons Community to have a crud. We have a working prototype based on bfg. Now we would like to rewrite it for Pyramid. I've received interesting feedback, but the most promising was pyramid_formalchemy posted by Gael.
What I miss in pyramid_formalchemy
I will start with description of our use case. At the moment we are using our CRUD to handle most of the form generation and CRUD operations. We are using it in several projects, one of them with ca. 100 models. The part of the application that is exposed to anonymous user (like registration) or it's more complex (like wizard multip-step forms) we are handling with formish. For those 100 models we are using heavily ZCA for customizing View/List templates. As far I can see in the pyramid_formalchemy source code:
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): ... config.add_view(context='pyramid_formalchemy.resources.ModelListing', renderer='pyramid_formalchemy:templates/admin/listing.pt', attr='listing', request_method='GET', permission='view', **kw)
you can only pass one ModelView for config registration and practically you can't customize any of the templates per model.
What we would actually like to have is a ZCA registration, like:
<view for=".interfaces.IModel" view=".listing" renderer="templates/my_model_listing.pt" permission="list" />
ZCML is of course optional...
Other benefit of this approach is a possibility to register other non-crud views (not only list/add/view/edit/delete) only for specific model (can be helpful for some of the widgets implementation, i.e. autocomplete).
This is our main concern.
At the end we miss some widgets (which should be part of fa.jquery project and can be extended easily). One of the most interesting one is relation widget (with several variations), which right now is missing :-)