> >
> > One possible solution (or workaround) could be to so_to_dict SO
> > instances in validators.Schema.from_python.... Though maybe a final
> > solution would be to fix fastdata to send a "so_to_dicted"
> SO to the
> > form...Opinions?
>
> I vote for removing getattr use from retrieve_value_by_path
> and using so_to_dict when passing values from FastData to
> widgets, we should support only one way of doing things there
> and this should be a canonical dict since this is also what
> FE expects.
Actuall, if I got you right I was doing something like this with my
fastdata-based code.
I needed to add extra parameter to fastdata form and end up with something
like:
@turbogears.expose()
def edit(self, obj):
referrer = cherrypy.request.headers.get("Referer", "")
obj = ObjectWrapper(obj)
obj['referrer'] = referrer
return dict(obj=obj, ...)
class ObjectWrapper:
"""Small utility classes that wraps SQLObject object
used in fastdata-based forms to be able to add other (non-object) fields
to it.
"""
def __init__(self, obj, **kw):
self.__obj = obj or {}
self.__kw = kw
def __setitem__(self, key, value):
self.__kw[key] = value
def __getattr__(self, key):
try:
return getattr(self.__obj, key)
except AttributeError:
pass
try:
return self.__kw[key]
except KeyError:
pass
raise AttributeError(key)
Ugly. Fastdata sucks, I'll say. ;)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---