On Jan 30, 2007, at 1:39 PM, Patrick Lewis wrote:

>
> I was toying around with FastData2 (from Alberto's svn), and had a few
> questions.

Keep in mind is still an (for the moment stalled) experiment... the  
name shouldn't impliy it would become TG's "official" fastdata which  
is still in need of a maintainer... fastdata2 is just an idea I had  
for a basis to build upon, nothing definitive yet so any other  
approaches to the problem are equally valid.
>
> - Looks like there are two generic operations, getting data
> (IDataHandler) and getting widgets (widget_for).  I guess I'm not
> clear on the IDataHandler what the 'controller' parameter would be
> used for.  It seems I could write a SA IDataHandler and not really
> care about what the controller is given the wsgi environ and a few
> standardized keywords, but I could be missing something.

The controller method is passed in case a rule wants to dispatch on  
it. IDataHandler's metaclass makes methods listed at the  
generic_methods attribute generic functions behind the scenes (see  
tests/test_meta.py). However, I'm not sure if passing it would be  
useful or even counter-productive, ideally the handler should have no  
knowledge of the controller which in this model it's supposed to  
handle the framework specific stuff like reading headers, set status  
codes, etc... I'm not even sure that passing environ around would be  
beneficial as it exposes too much of the framework's internals,  
though it can be handy to access services provided by upstream layers  
(like an authorization service)

>
> - I assume that IDataHandler.do_retrieve needs to handle returning
> multiple objects and just a single instance. Should do_retrieve always
> return a list, or should there be a keyword (or separate method) that
> indicates that you really only want *one* object.

I think the implementation would be easier if it always returns a  
list (or iterable?), even if it is len(1) or only yields one element.
>
> - On the widgets side (widget_for), how do I override the default
> behavior? For instance, in the user object, say I want to hide the
> 'user_name' field, drop the 'password' field (never ever gets sent to
> the browser), and format the 'user_balance' field in "X,XX0.00"
> format? I assume that's through **kw somehow, and perhaps it isn't
> that big of a concern right now.

Yep, it'll be through a special kw (application specific). For  
example you could do:

@widget_for.when("isinstance(obj, CorporateUser)")
def _widget_for_CUser(obj, cls, **kw):
        return a_widget
>
> - For that matter, how do I specify what 'mode' I am in (edit, view)?
> Is that what the 'action' keyword is for? (from the example, it looks
> like action got tacked onto the id, but perhaps that is just to
> demonstrate how the generic works).

Yep, it could be through an "action" keyword or anything that makes  
sense to the application. Not sure about how it got tacked onto the  
id, probably was just an example...
>
> - I had some trouble read() ing from
> cherrypy.request.wsgi_environ['wsgi.input'] inside of a controller (it
> would timeout).  This is in CP 2.2. I can take it to the CherryPy list
> if no one has run across this.

Hmmm, no idea there... :( probably the file obj got consumed by cp  
somewhere along the request...

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