[Zope-dev] Fw: PythonMethods and ZClass generation problem

Alexander Limi alexander@limi.net
Thu, 18 Jan 2001 18:02:16 +0100


Sorry if I'm overstepping any bounds here, but I tried posting this to the
main list, but the answers I get do not help me. I figured maybe somebody on
the PTK- or the Dev-list might be able to help. This is a bit of a crisis,
since our site has been down for a week due to this problem.

I also discovered that Zope 2.3 has PythonScript which has the "context"
object. Would this be of any help in the following problem? Just a thought.

This is my original posting:

> Hi,
>
> We recently decided to use LoginManager for authentication on our site,
and
> refactored our user registration methods to use PythonMethods instead of
> DTML.
>
> Now, during the registration of a user, we want to add a ZClass instance
> in the correct folder. This object is a representation of some of the
> information the user provides when he registers with us.
>
> But we have stumbled across a problem. This is probably a very basic and
> simple problem, but I couldn't find any info on it on zope.org, and none
of
> the people on IRC could help us either. So I'll try this posting instead.
:)
>
> What we're trying to do is to add a ZClass instance/object
programmatically
> from a PythonMethod. Our constructor is called Artist_add, and resides in
> our product "Artist". The constructor uses variables
> that we have set in the REQUEST object.
>
> So the process is like this:
>
> User fills out form with variables that are put in REQUEST
>   |
> Form calls "registerartist", which is a PythonMethod
>   |
> "registerartist" creates the user
>   |
> "registerartist" tries to call the constructor of our Artist ZClass to add
> an Artist object in our "artists" folder, but fails.
>
> To add the Artist object we tried to call the constructor in the following
> way from "registerartist":
>
> return self.artists.manage_addProduct['Artist'].Artist_add(_.None,_)
>
> but then the REQUEST object was not available, and the object creation
fails
> since it can't find the variables it needs. The traceback for this was:
>
> File <string>, line 41, in registerartist (Object:
> ApplicationDefaultPermissions) File
> /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 168, in __call__
(Object:
> Artist_add) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py,
> line 531, in __call__ (Object: Artist_add) IndexError: (see above)
>
>
>
> So we tried a different approach:
>
> return self.artists.manage_addProduct['Artist'].Artist_add(_.None,REQUEST)
>
> This solved the problem with REQUEST not being available, we can view its
> variables now, but now we can't
> access Artist.createInObjectManager. The error message we get is:
> "NameError Artist".
>
> So, I guess the question is: how can I add a ZClass instance
> programmatically from a PythonMethod based on data in the
> REQUEST object?
>
> Additional version info:
> Zope 2.2.4
> PythonMethod 0-1-7
> LoginManager 0-8-8b1
> ZPatterns 0-4-3b1
> DataSkinAddons 0-0-2
> Membership 0.7.8
>
>
>
> Thanks in advance,
>
>
> Alexander.