[Zope] define a class in a python script
Peter Sabaini
peter at sabaini.at
Wed Mar 5 04:39:06 EST 2008
On Wednesday 05 March 2008 10:21:32 Yuri wrote:
> Hi, all!
>
> I would like to define a class inside a python script (so I can catalog
> it and use catalog to store info, as the tutorial about catalog
> everything suggests).
The default Script(Python) objects dont support class definition, because of
security constraints.
One easy option would be to just use some other object, eg. a "File" and use
its properties.
Another option (with more initial effort, but easier to maintain later on) is
to implement a custom Product; have a look at
http://www.zope.org/Documentation/Books/ZDG/current on how to do this.
hth
peter.
> So I've done:
>
> ========
> class Autore:
> " classe per il catalogo "
>
> def set_autore(self, autore=''):
> """ setta l'autore """
> self.autore=autore
>
> def set_variante(self, variante=''):
> """ setta l'autore """
> self.variante = variante
>
> def variante(self):
> """ ritorna la variante """
> return self.variante
>
> def set_qualificazione(self, qualificazione=''):
> """ setta la qualificazione """
> self.qualificazione = qualificazione
>
> def qualificazione(self):
> """ ritorna la qualificazione """
> return self.qualificazione
>
>
> un_autore = Autore()
> un_autore.set_autore('prova')
> un_autore.set_variante('una variante')
> un_autore.set_qualificazione('una qualificazione')
>
> print un_autore.variante()
> print un_autore.qualificazione()
>
> return printed
>
> ======
>
> but zope complains about I can call the methods of this class:
>
> *Error Type: Unauthorized*
> *Error Value: You are not allowed to access set_autore in this context
>
> So, what can I do? How can I create virtual objects to be cataloged?
> *
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
More information about the Zope
mailing list