On Jan 25, 2007, at 9:07 PM, fumanchu wrote:

>
> I wrote:
>> I'll trade you better Tool docs for better TW docs. ;) I'm a bit lost
>> on how the various components actually work: who calls whom when.
>
> and Alberto replied:
>> Are you meaning TG or TW?, if the later (toscawidgets) I think
>> discussing it's docs deserves another thread... ;)
>
> Yes, I meant toscawidgets. Another thread is fine.

Ok, open it when you want... It's true that Tosca and TG widgets docs  
are pretty scarce so improving them will be good. Any specific  
question? I must admit I'm in a very bad position for documenting  
right now because I have no idea what people expect from TW widgets  
or how they see them... It's been so much time since I struggled  
about a year ago to grasp Kevin's and Michele's idea of them that I  
see myself too much inmersed in them...

They really don't do something very fancy expect moving and massaging  
variables from the display into a template. Most of the code is meta- 
programming to reduce boiler-plate (binding variables sent to the  
constructor into the instance, making them available at the dict that  
will feed the template passing it thorugh update_params so it can be  
modified for every request, moving variables from parent widgets to  
child widgets, etc...).

So widgets only "do something" on three moments:

1) When a widget subclass is built.
      By a metaclass. Nothing fancy, the __init__ method is wrapped  
with pre and post hooks and a serial number is assigned so widget  
lists can be possible.
2) when a widget is initialized. Also a set of valid parameters are  
picked from all bases.
     - pre init hooks are called which attach child widgets to the  
widget instance. Some magic goes in here due the fact that widgets  
cannot be modified once initialized so already initialized children  
must be cloned to assign them a new parent (the widget being  
initialized)
    - the init methods are called cooperatively. where widget  
subclasses must fix their initial state from the parameters given to  
the constructor... they are free to attach new children, create  
javascript code that shall initialize the widget, etc...
    - post init hooks are called. some things can only be done at  
this time, like generating schema validators for compound widgets as  
it0's the only time when we can know exactky how many children a  
widget has
3) when the widgets are being displayed:
    - "params" (which shall better be called "template_vars" but they  
keep their old name) are copied from the instance into a dict that  
gets filtered thorugh
     update_params to feed the template, then the widget calls the  
engine manager to select a template plugin that shall display the  
widget.


>
> Later, I wrote:
>> I would be quite interested in folding any such app_factory interface
>> back into CherryPy itself. I think this is an area where we can
>> co-develop quite well. For example, could this be solved by having  
>> the
>> CherryPy Application class grow a new app_factory (class)method?
>
> ...and Alberto replied:
>> Hmm, only if entry_points can be made to point to a classmethod
>> which I believe they can't...
>
> That's OK. An instancemethod could be equally helpful:
>
> class Application(object):
>     ...
>     def factory(self, global_conf, **local_conf):
>         self.merge(local_conf)
>         return self
>
> ----
> Then, in your TG app code:
>
> app = cherrypy.tree.mount(root, "/", conf)
> ----
> And in the paste config file:
>
> paste.app_factory = mymodule.app.factory

I've just tried it out and both class/instancemethods can be loaded  
by an entry_point.

Well, gotta go now.... please ask some specific questions reagrding  
TW and I'll try my best to answer them... hopefully the conversation  
will enable me to write better docs. :)

Alberto


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