Re: [SQLObject] Problems with str() on SQLObjects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Simen B. <si...@lu...> - 2003-05-10 14:52:02
|
I get this message afer it's been looping for a while: RuntimeError: maximum recursion depth exceeded The code producing it is a function called xmlrepr which basically takes some basic python types and turns them into an xml document: -- BEGIN xmlify.py -- from types import ListType, DictionaryType, InstanceType def xmlrepr(object, name): if type(object) =3D=3D ListType: xml =3D "<%s>" % name for item in object: xml+=3D xmlrepr(item, "item") xml =3D xml + "</%s>" % name return xml elif type(object) =3D=3D DictionaryType: xml =3D "<%s>" % name for (key, value) in object.items(): xml+=3D xmlrepr(value, key) xml =3D xml + "</%s>" % name return xml else: return "<%s>%s</%s>" % (name, object, name) -- END xmlify.py -- The code invoking this is here: -- BEGIN Main.py -- def list(self): """Lists the current entries.""" entries =3D [] for entry in Entry.select('all'): entries.append(entry.content()) self.model =3D entries -- END -- Where Entry is an SQLObject: -- BEGIN entry.py -- class Entry(SQLObject): _columns =3D [IntCol('date', default=3DNone), Col('content', = default=3DNone), IntCol('mood', default=3D5)] _connection =3D SQLiteConnection('C:/Home/Projects/blog/blog.db', = debug=3D1) def content(self): return {'date': self.date, 'content': self.content, 'mood': self.mood} -- END entry.py -- Hope that helped :) ----- Original Message -----=20 From: "Brad Bollenbach" <br...@bb...> To: <si...@lu...> Sent: Saturday, May 10, 2003 4:42 PM Subject: Re: [SQLObject] Problems with str() on SQLObjects > Date: Sat, 10 May 2003 09:14:52 -0500 > From: Brad Bollenbach <br...@bb...> > To: sql...@li... > Subject: Re: [SQLObject] Problems with str() on SQLObjects > > On 05/10/03 14:49, Simen Brekken wrote: > > Hi, I'm working on an MVC app and I'm using SQLObject for the Model = part of it, however I'm having some problems getting the values of normal = string columns: > > > > File "...\xmlify.py", line 22, in xmlrepr > > return "<"+name+">"+str(object)+"</"+name+">" > > File "C:\Utils\Python\Lib\site-packages\SQLObject\SQLObject.py", = line 834, in __repr__ > > return '<%s %i %s>' \ > > File "C:\Utils\Python\Lib\site-packages\SQLObject\SQLObject.py", = line 843, in _reprItems > > r =3D repr(value) > > File "C:\Utils\Python\Lib\site-packages\SQLObject\SQLObject.py", = line 834, in __repr__ > > > > It runs into an infinite loop! 'object'. The strange thing is that = this only happens to Col() or StringCol() types, IntCol() works fine. > > Can you post the error message after the traceback or is it just a > simple KeyboardInterrupt from getting out of the infinite loop (if in > fact it's an infinite loop)? > > Also, a simple test case to reproduce the bug will shorten the > distance between problem and solution. > > --=20 > Brad Bollenbach > BBnet.ca > > =20 ___ SIMEN BREKKEN / born to synthesize. |