Christopher Arndt schrieb:
> Kirk Strauser schrieb:
>> On Wednesday 15 October 2008 11:08:28 Diez B. Roggisch wrote:
>>
>>> userform.display(dict(password="fake", passwordverify="fake",
>>> username=<the-real-username>))
>> OK, let me generalize that question slightly.
>>
>> Suppose I have a huge form based on a model with a lot of fields, and I'm 
>> displaying it with "fooform.display(value=foo)".  I want to override one of 
>> the values like we're talking about here.  Is there a way to change just one 
>> value without switching to enumerating every single field?
> 
> I suppose "foo" is a model object?
> 
> You could provide a method on foo that turns it into a dict and then
> updates the value on this dict that you want to overwrite and then pass
> this dict instead:
> 
> def showform(self, id):
>    modelinst = ModelObj.get(id)
>    # returns dict(attribute1=..., attribute2=...) etc.
>    data = modelinst.to_dict()
>    data.update({'password': 'fake'})
>    return dict(fooform=myform, foo=data)

This method shoulb be already there. He can use the jsonify-call, which 
reflects over SO-objects.


Elixir has a to-dict-like method as well on it's objects.

Diez

--~--~---------~--~----~------------~-------~--~----~
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