From pete-lists at bcmpweb.com Thu Mar 30 13:40:30 2006 From: pete-lists at bcmpweb.com (Peter Simmons) Date: Thu, 30 Mar 2006 23:40:30 +1200 Subject: [Z3-sqlos] newby tutorial, examples Message-ID: <442BC3AE.8090705@bcmpweb.com> Hi, Just wondering if there are any tutorial's or examples of using sqlos to use SQLObject with Zope3? Cheers, Pete From stephane_brault at yahoo.fr Thu Mar 30 17:03:11 2006 From: stephane_brault at yahoo.fr (=?iso-8859-1?q?St=E9phane=20Brault?=) Date: Thu, 30 Mar 2006 17:03:11 +0200 (CEST) Subject: [Z3-sqlos] add and sqlmeta errors Message-ID: <20060330150311.72628.qmail@web26515.mail.ukl.yahoo.com> Hi, I'm using sqlos for a zope 3 project using an existing mysql database. Following the tutorial, I was able to create a table object as well as a container. I also had to add a sqlmeta class. Everything works fine except : - when I try to add an object, I get the following error : Traceback (innermost last): Module zope.publisher.publish, line 138, in publish result = publication.callObject(request, object) Module zope.app.publication.zopepublication, line 161, in callObject return mapply(ob, request.getPositionalArguments(), request) Module zope.publisher.publish, line 113, in mapply return debug_call(object, args) - __traceback_info__: Module zope.publisher.publish, line 119, in debug_call return object(*args) Module zope.app.pagetemplate.simpleviewclass, line 44, in __call__ return self.index(*args, **kw) Module zope.app.pagetemplate.viewpagetemplatefile, line 83, in __call__ return self.im_func(im_self, *args, **kw) Module zope.app.pagetemplate.viewpagetemplatefile, line 51, in __call__ sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0), Module zope.pagetemplate.pagetemplate, line 117, in pt_render strictinsert=0, sourceAnnotations=sourceAnnotations)() Module zope.tal.talinterpreter, line 277, in __call__ self.interpret(self.program) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 908, in do_useMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 538, in do_optTag_tal self.do_optTag(stuff) Module zope.tal.talinterpreter, line 523, in do_optTag return self.no_tag(start, program) Module zope.tal.talinterpreter, line 518, in no_tag self.interpret(program) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 878, in do_defineMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 976, in do_defineSlot self.interpret(block) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 966, in do_defineSlot self.interpret(slot) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 878, in do_defineMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 878, in do_defineMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 588, in do_setLocal_tal self.engine.setLocal(name, self.engine.evaluateValue(expr)) Module zope.tales.tales, line 696, in evaluate return expression(self) - C:\Python24\Lib\site-packages\zope\app\form\browser\add.pt - Line 19, Column 8 - Expression: - Names: {'args': (), 'context': , 'default': , 'loop': {}, 'nothing': None, 'options': {}, 'repeat': {}, 'request': , 'template': , 'usage': , 'view': , 'views': } Module zope.tales.expressions, line 205, in __call__ return self._eval(econtext) Module zope.tales.expressions, line 199, in _eval return ob() Module zope.app.form.browser.add, line 62, in update self.createAndAdd(data) Module zope.app.form.browser.add, line 93, in createAndAdd content = self.create(*args, **kw) Module zope.app.form.browser.add, line 74, in create return self._factory(*args, **kw) Module sqlobject.main, line 1183, in __init__ self._create(id, **kw) Module sqlobject.main, line 1202, in _create raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, column.name) TypeError: Categories() did not get expected keyword argument CategoryID I must say that the CategoryID is in the form and is declared in the class. - When I copy paste an object, I get : Module zope.publisher.publish, line 138, in publish result = publication.callObject(request, object) Module zope.app.publication.zopepublication, line 161, in callObject return mapply(ob, request.getPositionalArguments(), request) Module zope.publisher.publish, line 113, in mapply return debug_call(object, args) - __traceback_info__: > Module zope.publisher.publish, line 119, in debug_call return object(*args) Module zope.app.pagetemplate.viewpagetemplatefile, line 83, in __call__ return self.im_func(im_self, *args, **kw) Module zope.app.pagetemplate.viewpagetemplatefile, line 51, in __call__ sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0), Module zope.pagetemplate.pagetemplate, line 117, in pt_render strictinsert=0, sourceAnnotations=sourceAnnotations)() Module zope.tal.talinterpreter, line 277, in __call__ self.interpret(self.program) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 908, in do_useMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 538, in do_optTag_tal self.do_optTag(stuff) Module zope.tal.talinterpreter, line 523, in do_optTag return self.no_tag(start, program) Module zope.tal.talinterpreter, line 518, in no_tag self.interpret(program) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 878, in do_defineMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 976, in do_defineSlot self.interpret(block) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 966, in do_defineSlot self.interpret(slot) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 878, in do_defineMacro self.interpret(macro) Module zope.tal.talinterpreter, line 352, in interpret handlers[opcode](self, args) Module zope.tal.talinterpreter, line 588, in do_setLocal_tal self.engine.setLocal(name, self.engine.evaluateValue(expr)) Module zope.tales.tales, line 696, in evaluate return expression(self) - C:\Python24\Lib\site-packages\zope\app\container\browser\contents.pt - Line 7, Column 4 - Expression: - Names: {'args': (), 'context': , 'default': , 'loop': {}, 'nothing': None, 'options': {}, 'repeat': {}, 'request': , 'template': , 'usage': , 'view': , 'views': } Module zope.tales.expressions, line 205, in __call__ return self._eval(econtext) Module zope.tales.expressions, line 199, in _eval return ob() Module zope.app.container.browser.contents, line 92, in listContentInfo self.pasteObjects() Module zope.app.container.browser.contents, line 389, in pasteObjects copier.copyTo(target) Module zope.app.copypastemove, line 408, in copyTo copy = locationCopy(obj) Module zope.app.location.pickling, line 76, in locationCopy pickler.dump(loc) PicklingError: Can't pickle : attribute lookup sqlobject.declarative.sqlmeta failed. Any hint ? Thanks, St?phane ___________________________________________________________________________ Nouveau : t?l?phonez moins cher avec Yahoo! Messenger ! D?couvez les tarifs exceptionnels pour appeler la France et l'international. T?l?chargez sur http://fr.messenger.yahoo.com From stephane_brault at yahoo.fr Thu Mar 30 17:20:20 2006 From: stephane_brault at yahoo.fr (=?iso-8859-1?q?St=E9phane=20Brault?=) Date: Thu, 30 Mar 2006 17:20:20 +0200 (CEST) Subject: [Z3-sqlos] add and sqlmeta errors In-Reply-To: <20060330150311.72628.qmail@web26515.mail.ukl.yahoo.com> Message-ID: <20060330152020.19039.qmail@web26512.mail.ukl.yahoo.com> The preceding post was a bit hard to read, my mistake ;-). Here is a more readable version : Hi, I'm using sqlos for a zope 3 project using an existing mysql database. Following the tutorial, I was able to create a table object as well as a container. I also had to add a sqlmeta class. Everything works fine except : - when I try to add an object, I get the following error : TypeError: Categories() did not get expected keyword argument CategoryID I must say that the CategoryID is in the form and is declared in the class. - When I copy paste an object, I get : PicklingError: Can't pickle : attribute lookup sqlobject.declarative.sqlmeta failed. Any hint ? Thanks, St?phane ___________________________________________________________________________ Nouveau : t?l?phonez moins cher avec Yahoo! Messenger ! D?couvez les tarifs exceptionnels pour appeler la France et l'international. T?l?chargez sur http://fr.messenger.yahoo.com From jinty at web.de Thu Mar 30 17:21:25 2006 From: jinty at web.de (Brian Sutherland) Date: Thu, 30 Mar 2006 17:21:25 +0200 Subject: [Z3-sqlos] newby tutorial, examples In-Reply-To: <442BC3AE.8090705@bcmpweb.com> References: <442BC3AE.8090705@bcmpweb.com> Message-ID: <20060330152125.GA7317@minipas.home> On Thu, Mar 30, 2006 at 11:40:30PM +1200, Peter Simmons wrote: > Hi, > > Just wondering if there are any tutorial's or examples of using sqlos to > use SQLObject with Zope3? Yes there is a tutorial included with the source, but I think it's a bit out of date. Probably the best way is to look at the functional testing harness, that is a mini application in it's own right. It is also guaranteed to be correct. Probably the best place to ask questions is this list, or #z3-base on freenode. > Cheers, > Pete > _______________________________________________ > z3-sqlos mailing list > z3-sqlos at codespeak.net > http://codespeak.net/mailman/listinfo/z3-sqlos > -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!" From jinty at web.de Thu Mar 30 17:42:48 2006 From: jinty at web.de (Brian Sutherland) Date: Thu, 30 Mar 2006 17:42:48 +0200 Subject: [Z3-sqlos] add and sqlmeta errors In-Reply-To: <20060330152020.19039.qmail@web26512.mail.ukl.yahoo.com> References: <20060330150311.72628.qmail@web26515.mail.ukl.yahoo.com> <20060330152020.19039.qmail@web26512.mail.ukl.yahoo.com> Message-ID: <20060330154248.GC7317@minipas.home> On Thu, Mar 30, 2006 at 05:20:20PM +0200, St??phane Brault wrote: > The preceding post was a bit hard to read, my mistake > ;-). Here is a more readable version : > > Hi, > I'm using sqlos for a zope 3 project using an > existing > mysql database. Following the tutorial, I was able > to > create a table object as well as a container. I also > had to add a sqlmeta class. Everything works fine > except : > - when I try to add an object, I get the following > error : > TypeError: Categories() did not get expected keyword > argument CategoryID > I must say that the CategoryID is in the form and is > declared in the class. I've seen this before and believe it is more an issue with SQLObject rather than SQLOS. There may be a better response from the SQLObject docs or list. I seem to remember that SQLObject is very picky with what the names of attributes and columns are. This is especially a problem when you try to use an existing database. > - When I copy paste an object, I get : > PicklingError: Can't pickle 'sqlobject.declarative.sqlmeta'>: attribute lookup > sqlobject.declarative.sqlmeta failed. Are you inheriting from SQLOS and Persistent, or pasting into a persistent container?? Because zope is trying to put your SQLObject into the ZODB... Please bear in mind that SQLOS still doesn't work very well through the ZMI. People have generally been using it for projects where they replace the ZMI completely. > > Any hint ? > > Thanks, > > St?phane > > > > > > > ___________________________________________________________________________ > Nouveau : t?l?phonez moins cher avec Yahoo! Messenger ! D?couvez les tarifs exceptionnels pour appeler la France et l'international. > T?l?chargez sur http://fr.messenger.yahoo.com > _______________________________________________ > z3-sqlos mailing list > z3-sqlos at codespeak.net > http://codespeak.net/mailman/listinfo/z3-sqlos > -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!" From stephane_brault at yahoo.fr Thu Mar 30 18:05:43 2006 From: stephane_brault at yahoo.fr (=?iso-8859-1?q?St=E9phane=20Brault?=) Date: Thu, 30 Mar 2006 18:05:43 +0200 (CEST) Subject: [Z3-sqlos] add and sqlmeta errors In-Reply-To: <20060330154248.GC7317@minipas.home> Message-ID: <20060330160543.15259.qmail@web26501.mail.ukl.yahoo.com> Thanks Brian, --- Brian Sutherland a ?crit : > On Thu, Mar 30, 2006 at 05:20:20PM +0200, St??phane > Brault wrote: > > The preceding post was a bit hard to read, my > mistake > > ;-). Here is a more readable version : > > > > Hi, > > I'm using sqlos for a zope 3 project using an > > existing > > mysql database. Following the tutorial, I was > able > > to > > create a table object as well as a container. I > also > > had to add a sqlmeta class. Everything works fine > > except : > > - when I try to add an object, I get the > following > > error : > > TypeError: Categories() did not get expected > keyword > > argument CategoryID > > I must say that the CategoryID is in the form and > is > > declared in the class. > > I've seen this before and believe it is more an > issue with SQLObject > rather than SQLOS. There may be a better response > from the SQLObject > docs or list. > > I seem to remember that SQLObject is very picky with > what the names of > attributes and columns are. This is especially a > problem when you try to > use an existing database. > That is why I declared a sqlmeta class in my class, the problem only arises with one field, which is strange. It doesn't have any problem when retrieving the rows or updating. > > - When I copy paste an object, I get : > > PicklingError: Can't pickle > 'sqlobject.declarative.sqlmeta'>: attribute lookup > > sqlobject.declarative.sqlmeta failed. > > Are you inheriting from SQLOS and Persistent, or > pasting into a > persistent container?? Because zope is trying to put > your SQLObject into > the ZODB... > > Please bear in mind that SQLOS still doesn't work > very well through the > ZMI. People have generally been using it for > projects where they replace > the ZMI completely. > I know this might be asked elsewhere, but is it easy to replace the ZMI ? St?phane ___________________________________________________________________________ > > > Nouveau : t?l?phonez moins cher avec Yahoo! > Messenger ! D?couvez les tarifs exceptionnels pour > appeler la France et l'international. > > T?l?chargez sur http://fr.messenger.yahoo.com > > _______________________________________________ > > z3-sqlos mailing list > > z3-sqlos at codespeak.net > > http://codespeak.net/mailman/listinfo/z3-sqlos > > > > -- > Brian Sutherland > > Metropolis - "it's the first movie with a robot. And > she's a woman. > And she's EVIL!!" > ___________________________________________________________________________ Nouveau : t?l?phonez moins cher avec Yahoo! Messenger ! D?couvez les tarifs exceptionnels pour appeler la France et l'international. T?l?chargez sur http://fr.messenger.yahoo.com From stephane_brault at yahoo.fr Thu Mar 30 19:24:18 2006 From: stephane_brault at yahoo.fr (=?iso-8859-1?q?St=E9phane=20Brault?=) Date: Thu, 30 Mar 2006 19:24:18 +0200 (CEST) Subject: [Z3-sqlos] add and sqlmeta errors In-Reply-To: <20060330150311.72628.qmail@web26515.mail.ukl.yahoo.com> Message-ID: <20060330172418.97875.qmail@web26504.mail.ukl.yahoo.com> I found the answer to the adding problem : the field was required and there was no default value. If a default value is added, there is no longer any problem. St?phane ___________________________________________________________________________ Nouveau : t?l?phonez moins cher avec Yahoo! Messenger ! D?couvez les tarifs exceptionnels pour appeler la France et l'international. T?l?chargez sur http://fr.messenger.yahoo.com From jinty at web.de Thu Mar 30 19:43:57 2006 From: jinty at web.de (Brian Sutherland) Date: Thu, 30 Mar 2006 19:43:57 +0200 Subject: [Z3-sqlos] add and sqlmeta errors In-Reply-To: <20060330160543.15259.qmail@web26501.mail.ukl.yahoo.com> References: <20060330154248.GC7317@minipas.home> <20060330160543.15259.qmail@web26501.mail.ukl.yahoo.com> Message-ID: <20060330174357.GA7283@minipas.home> On Thu, Mar 30, 2006 at 06:05:43PM +0200, St?phane Brault wrote: > > > create a table object as well as a container. I > > also > > > had to add a sqlmeta class. Everything works fine > > > except : > > > - when I try to add an object, I get the > > following > > > error : > > > TypeError: Categories() did not get expected > > keyword > > > argument CategoryID > > > I must say that the CategoryID is in the form and > > is > > > declared in the class. > > > > I've seen this before and believe it is more an > > issue with SQLObject > > rather than SQLOS. There may be a better response > > from the SQLObject > > docs or list. > > > > I seem to remember that SQLObject is very picky with > > what the names of > > attributes and columns are. This is especially a > > problem when you try to > > use an existing database. > > > > That is why I declared a sqlmeta class in my class, > the problem only arises with one field, which is > strange. It doesn't have any problem when retrieving > the rows or updating. Yeah, it normally happens when the attribute name is different to what sqlobject expects. I normally haul out the python debugger at this point, or start printing out SQL (which you can do by setting debug=1 in sqlos.adapter). Hopefully SQLObject 2 will be better about this. > > > - When I copy paste an object, I get : > > > PicklingError: Can't pickle > > 'sqlobject.declarative.sqlmeta'>: attribute lookup > > > sqlobject.declarative.sqlmeta failed. > > > > Are you inheriting from SQLOS and Persistent, or > > pasting into a > > persistent container?? Because zope is trying to put > > your SQLObject into > > the ZODB... > > > > Please bear in mind that SQLOS still doesn't work > > very well through the > > ZMI. People have generally been using it for > > projects where they replace > > the ZMI completely. > > > > I know this might be asked elsewhere, but is it easy > to replace the ZMI ? Replacing the ZMI is actually what people normally do. Just have a look at https://launchpad.net/ or schooltool (The app, not the website) for examples. I have never had a customer I can show the ZMI too;) Normally they want something simpler with a custom design... -- Brian Sutherland Metropolis - "it's the first movie with a robot. And she's a woman. And she's EVIL!!"