From: tsume <ts...@ts...> - 2007-04-01 07:37:01
|
I'm not 100% sure how the KidKit plugin works, but I've the problem below. I created a test app so I could play with SQLObject. Everything went fine until I changed the page which was running fine already. The code added a person to the database. The problem occurs when I change the code. Unless I restart the server, the next query will print out the error below. I've attached my example code as well at the end of this post. Traceback (most recent call last): File "./WebKit/Application.py", line 477, in dispatchRawRequest [edit] File "./WebKit/Application.py", line 539, in runTransaction [edit] File "./WebKit/URLParser.py", line 69, in findServletForTransaction [edit] File "./WebKit/URLParser.py", line 301, in parse [edit] File "./WebKit/URLParser.py", line 412, in parse [edit] File "./WebKit/URLParser.py", line 844, in servletForFile [edit] File "./WebKit/ServletFactory.py", line 230, in servletForTransaction [edit] File "./KidKit/KidServletFactory.py", line 147, in loadClass [edit] File "/usr/lib/python2.5/site-packages/kid-0.9.5-py2.5.egg/kid/__init__.py", line 158, in load_template [edit] store=cache, ns=ns, exec_module=exec_module) File "/usr/lib/python2.5/site-packages/kid-0.9.5-py2.5.egg/kid/importer.py", line 144, in _create_module [edit] raise_template_error(module=name, filename=filename) File "/usr/lib/python2.5/site-packages/kid-0.9.5-py2.5.egg/kid/importer.py", line 141, in _create_module [edit] exec code in mod.__dict__ File "/home/tsume/appserver/TestApp/MyContext/What.py", line 27, in <module> [edit] File "/usr/lib/python2.5/site-packages/sqlobject/declarative.py", line 109, in __new__ [edit] cls.__classinit__(cls, new_attrs) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 805, in __classinit__ [edit] classregistry.registry(cls.sqlmeta.registry).addClass(cls) File "/usr/lib/python2.5/site-packages/sqlobject/classregistry.py", line 91, in addClass [edit] '__file__', '(unknown)'))) ValueError: class Person is already in the registry (other class is <class 'kid.util.template_66e30851.Posds'>, from the module kid.util.template_66e30851 in (unknown); attempted new class is <class 'kid.util.template_66e30851.Posds'>, from the module kid.util.template_66e30851 in (unknown)) Error in code generated from template file '/home/tsume/appserver/TestApp/MyContext/What.kid' Example.kid <?xml version='1.0' encoding='utf-8'?> <?python from sqlobject import * import os, sys db_filename = os.path.abspath('data.db') connection_string = 'sqlite:' + db_filename connection = connectionForURI(connection_string) sqlhub.processConnection = connection class Person(SQLObject): firstname = StringCol() ?> <body py:strip="" xmlns:py="http://purl.org/kid/ns#"> <h3>Index of </h3> <div>${Person(firstname="blah blah")}</div> </body> |
From: Christoph Z. <ci...@on...> - 2007-04-01 14:24:16
|
tsume wrote: > I created a test app so I could play with SQLObject. Everything went fine > until I changed the page which was running fine already. The code added a > person to the database. The problem occurs when I change the code. Unless > I restart the server, the next query will print out the error below. I've > attached my example code as well at the end of this post. I assume you have deactivated caching by setting CacheKidTemplates = CacheServletClasses = CacheServletInstances = False This means the model will be reloaded whenever you change the template, and SQLObject does not like reloading the model. So you should define your database model in a different Python module, say Model.py which should live anywhere in your working dir. This makes a lot of sense anyway. Then in the header of the template you do <?python from Model import Person ... other servlet specific initialization ... ?> Now you can change your template code and see the changes immediately. If you change Model.py, then the AutoReload mechanism will reload Webware for you. Works perfectly well. Hope that helps, -- Chris |