Re: @form.action(attribut) überschreiben

Carsten Senger <[email protected]>
Newsgroups gmane.comp.web.zope.german
Message-ID <5B368690B0A6722ACE4BD564@[192.168.178.26]>
Hallo Vlad,

--On Freitag, Oktober 22, 2010 02:06:50 +0200 Vladislav Vorobiev 
<[email protected]> wrote:

> Hallo Zusammen!
>
> Ich habe folgende zwei Klassen:
>
> class GenericFormularEdit(EditForm):
>     description = _(u"Please fill out all fields to get more information")
>     form_fields = form.Fields(eval ('IEinEi')
>     addbutton   = u'APPLY'
>
>     @form.action(_(addbutton))
>     def action(self, actions, data)
>         pass
>
>
> class UserEdit(GenericFormularEdit):
>     form_fields = form.Fields(IUser)
>     description = _(u"Add Information")
>     addbutton   = u'APPLY MIT MEINEM TEXT'
>
>     def __call__(self):
>         return super(UserEdit, self).__call__()
>
> Wie kann erreichen, dass beim Aufruf der Klasse UserEdit ins
> @form.action(_(addbutton)) das 'addbutton'  attribute von der Kind
> Klasse also UserEdit eingesetzt wird?
> Beim Aufruf wird das Attribut der Vaterklasse eingesetzt also 'APPLY'
> soll aber 'APPLY MIT MEINEM TEXT'.
> Geht es Irgend wie? Ich möchte nicht die action() Methode neu definieren.

du kannst UserEdit.updateActions() benutzen, um die Actions zu verändern.
Du must aber vorher eine Kopie von GeneriFormularEdit.actions erstellen,
damit du nicht die Actions der Elternklasse änderst. Das kann seltsame
Effekte produzieren.
<http://zope3.mpg.de/cgi-bin/twiki/view/Zope/FormLib> dokumentiert das gut.

Da _(addform) beim der definition des decorators aufgerufen wirst Du mit
dem decorator nicht weiterkommen.

..Carsten


_______________________________________________
zope mailing list
[email protected]
https://mail.dzug.org/mailman/listinfo/zope
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.