On Jan 17, 2007, at 5:10 PM, [EMAIL PROTECTED] wrote:


Hi:

Recently I was thinking that DataController needs some refresh air, I
prefer the explicit code for edit rather than the DataController, which
works like the magic :-)

For example, Identity framework give us some explicit code in
controllers.py, so we could customize our identity requirement if the
default way is not exactly what we need. We should do more of this.

(snippet removed)

+1

I'd like to see TG 2.0 do more code-generation in general. Pylons is already doing it and I love that idea because it you can easily modify the created structure if you need to tweak or add new behavior.

However, a good balance between generated code and support libraries should be reached or else generated code will be harder to maintain if the template that generated it is updated with bug-fixes or new functionallity.

Pylons has a "paster restcontroller" CLI command which you might like to study for inspiration.

However, I think that widgets to view/edit/add model objecs whould be autogenerated like current FastData does because it would be hard to sync view/model code when the model is updated if code is autogenerated.

It would be nice if the generic function that returns individual fields could be extended to support whole model objects as a parameter. This would allow overriding the automatically generated widget by registering a new widget, for example:

class CreateUserForm(Form):
    ....

register_widget_for(User, action='create', CreateUserForm (action='save'))

register_widget_for would add a rule to the "widget_for" generic function so that when "widget_for(user_instance, action='create')" is called the registered widget is returned. If User is an SQLObject subclass and no widget had been registered, the default rule could create a form automatically much like FastData is doing now by recursing "widget_for" into it's attributes.

Due to the fact widget_for is a generic function, it can, for example, be customized to provide access rules to widgets (don't display some items in a menu bar if logged in user is not an Admin), etc... without crowding template code with that logic.

I have an implementation of this (similar to one I'm using in some apps) here:

http://svn.toscat.net/FastData2/fastdata2/view.py

However, it doesn't automatically create widgets for model fields yet but I'm planning to implement it taking code/ideas from TG's formmaker and QuickData (by thesamet) when I have some time.

All this sounds much like it belongs to 2.0's FastData... Would you like to join forces on this?

Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to