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 should also add a ZClass instance
in the correct forlder. 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 under the Control_Panel folder. 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, 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?

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.



_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to