[Zope] "Empty or invalid id specified" when trying to add a new product

Andreas Jung andreas at andreas-jung.com
Mon Feb 9 01:40:50 EST 2004



--On Sonntag, 8. Februar 2004 22:15 Uhr -0800 Alexander Busorgin 
<aleksandrmailbox at yahoo.com> wrote:

> Hi All,
> I've created a simple product, but I cant add it to
> folder. I get this error "Empty or invalid id
> specified"
> can you tell me where is a problem?
>
> thanks.
>
>
> __init__.py
> ========
> import helloMod
>
> def initialize(context):
>     context.registerClass(
>     helloMod.helloClass,
>     permission="HelloObj",
>     constructors=(helloMod.manage_addHelloForm,
>     helloMod.manage_addHello)
>     )
>
> helloMod.py
> ========
> from OFS.SimpleItem import Item
> from Globals import Persistent
> from Acquisition import Implicit
>
> def manage_addHelloForm(self, REQUEST):
>     "to add HelloObj"
>     return """
>     <html>
>     <head></head>
>     <body>
>     <form method="post" action="./manage_addHello">
>     <input type="text" name="id">
>     <input type="submit" value="Add HelloObj">
>     </form>
>     </body>
>     </html>
>     """
>
> def manage_addHello(self):
>     "to add HelloObj"
>     newHello = helloClass(id)
>     self._setObject(id, newHello)
>     return self.manage_main(self, REQUEST)
>
>

If you call manage_addHello with parameter 'id' then you *must* declare 
this parameter
in the declaration of of method of course. The error message you described 
also does not make
sense since your code raise another exception that 'id' is not declared 
inside manage_addHello().
So your code and your bugreport is somewhat out-of-sync. The error you 
described happens
if you try to create an object with an empty id.

-aj



More information about the Zope mailing list