"Empty or invalid id specified" when trying to add a new product
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) class helloClass(Item, Persistent, Implicit): def __init__(self, id, Name = 'hi'): self.id = id self.Name = Name meta_type = "HelloObj" def saySomething(self): return "Hi, " + self.Name def edit(self, Name): self.Name = Name __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html
--On Sonntag, 8. Februar 2004 22:15 Uhr -0800 Alexander Busorgin <aleksandrmailbox@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
Alexander Busorgin wrote at 2004-2-8 22:15 -0800:
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?
You want to look at the traceback! It tells you where the problem occured. This helps a lot... -- Dieter
participants (3)
-
Alexander Busorgin -
Andreas Jung -
Dieter Maurer