thanks, I think I´ve got it now.

the documentation of custom manipulators really lacks advanced examples.
I don´t know how one should find out what you explained in the last  
few mails by reading the documentation.
e.g., I´m quite sure that there´s no explanation of "_meta" in the  
documentation

anyway, thanks a lot.
patrick

Am 22.09.2006 um 08:42 schrieb Ivan Sagalaev:

>
> patrickk wrote:
>> I don´t want to stress your help, but do you know where to find an
>> example on using a custom manipulator for *updating* data.
>>
>> question is, where does the custom manipulator gets the data (stored
>> in the database) from.
>> the way I did it so far:
>> 1. using a changmanipulator to get and display the data
>> 2. using a custom manipulator to handle the form, do validation and
>> save the data
>>
>> when you´re saying that I should only use *one* manipulator, there
>> has to be a possibility to get the data with the custom manipulator.
>> something like: manipulator = UserProfile.MyCustomManipulator 
>> (user_id)
>
> Since it's custom manipulator it's all up to you how to retrieve data.
> The most straightforward way is to copy the common behavior: implement
> flatten_data:
>
>      class MyCustomManipulator(forms.Manipulator):
>        def __init__(self, id):
>          self.original_object = Model.objects.get(pk=id)
>          self.fields= [
>            ...
>          ]
>
>        def flatten_data():
>          return dict([(field.name, getattr(t, field.attname)) for  
> field
> in self.original_object._meta.fields])
>
> This is a very simple implementation of flatten_data. It doesn't  
> handle
> ManyToManyField for example. But the idea is that you have to return a
> dict with keys corresponding to your manipulator field names.
>
>> sorry for being slow off the mark here, but that really contradicts
>> my reading of the documentation.
>
> Why that? Docs never say that you should use different manipulators  
> for
> giving away and accepting data. However it really lacks more advanced
> examples of using custom manipulators...
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to