On Thu, 2007-27-12 at 05:36 +0200, alex bodnaru wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> hi friends,
> 
> i have a dynamic crud controller (table name as an __init__ parameter),
> that i wish to be part of a page, where also may be choosen the table to
> be crud.
> 
> could the entire crud controller (has only one template) be encapsulated
> as a widget?

You probably could, but having made the mistake of cramming too much
into widgets before and regretting it, I'd advise against it. Hard to
debug, easy to make RAM-pig apps. What I did recently that worked well
for me was to make a base class for a generic crud controller, and it
included generic view & edit widgets. Then it was easy to either
override the associated widget, or inherit from it, or only override the
template, but the whole underlying architecture was not tied to widgets.

I included a list of widget fields in the model, allowing the generic
controller to build the widgets by having a model class passed in. Brief
example

class Thing(object):
  _edit_fields = [ widget field list ]
  _list_fields = [ widget field list ]

Then the crud controller could do this

thing_controller = CrudController( Model=Thing, etc etc )

and it was able to make widgets in it's contstructor:

self.edit_widget = CrudEditWidget( fields=self.Model._edit_fields )

etc

If you are interested, I can post code, but it needs clean up. Works
though!

Iain



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to