The debug problem (see traceback below) I had is due to the code I used from the wiki: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GenericOrmBaseClass
The code does not work in 0.5 anymore, one reason is that the MyClass.c attribute is no longer there. I looked at the declarative stuff and I am thinking of switching over to it, but it still has the "problem" that each column name has to be typed five times (including the init and repr method stuff). O.K. this is only in the model, done once but still it opens things up for errors. Looking at "http://www.sqlalchemy.org/docs/05/ormtutorial.html#datamapping_declarative" it would be really nice if the "init" and "repr" methods are automagically generated, or maybe something like a mixin could be provided. In my test I added the following to MyClass and it works. But I am sure this is not the most elegant way of doing this and I am not sure how one changes this to a mixin without stuffing other things up. Would appreciate if anyone can push me in the right direction. Werner class Prefminimal(Base): __tablename__ = 'preferences' prefid = sa.Column(sa.Integer, sa.Sequence('gen_preferences_prefid'), primary_key=True, nullable=False) dbstructure = sa.Column(sa.Integer) dbdata = sa.Column(sa.Integer) # added stuff myColumns = [] for att in dir(): if not att.startswith(('_', 'myColumns')): myColumns.append(att) def __repr__(self): atts = [] for att in self.myColumns: atts.append( (att, getattr(self, att))) return self.__class__.__name__ + '(' + ', '.join(x[0] + '=' + repr(x[1]) for x in atts) + ')' Werner F. Bruhin wrote: > Traceback (most recent call last): > File "C:\Python25\Lib\site-packages\boa\Debugger\IsolatedDebugger.py", > line 823, in run > Bdb.run(self, cmd, globals, locals) > File "C:\Python25\lib\bdb.py", line 366, in run > exec cmd in globals, locals > File "<string>", line 1, in <module> > File "C:\Dev\twcb\Program\twcb.py", line 1108, in <module> > main() > File "C:\Dev\twcb\Program\twcb.py", line 1104, in main > appl = BoaApp() > File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", > line 7912, in __init__ > self._BootstrapApp() > File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", > line 7487, in _BootstrapApp > return _core_.PyApp__BootstrapApp(*args, **kwargs) > File "C:\Dev\twcb\Program\twcb.py", line 266, in OnInit > self.prefs = self.ds.query(db.prefminimal).get(1) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\session.py", > > line 894, in query > return self._query_cls(entities, self, **kwargs) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\query.py", > > line 97, in __init__ > self.__setup_aliasizers(self._entities) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\query.py", > > line 111, in __setup_aliasizers > mapper, selectable, is_aliased_class = _entity_info(entity, > ent.entity_name) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\util.py", > > line 401, in _entity_info > mapper = entity.compile() > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\mapper.py", > > line 370, in compile > mapper.__initialize_properties() > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\mapper.py", > > line 391, in __initialize_properties > prop.init(key, self) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\interfaces.py", > > line 378, in init > self.do_init() > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\properties.py", > > line 193, in do_init > strategies.DefaultColumnLoader(self)._register_attribute(None, None, > False, comparator_callable, proxy_property=self.descriptor) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\strategies.py", > > line 37, in _register_attribute > proxy_property=proxy_property > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\unitofwork.py", > > line 88, in register_attribute > return attributes.register_attribute(class_, key, *args, **kwargs) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\attributes.py", > > line 1407, in register_attribute > descriptor = proxy_type(key, proxy_property, comparator, parententity) > File > "c:\python25\lib\site-packages\sqlalchemy-0.5.0beta1-py2.5.egg\sqlalchemy\orm\attributes.py", > > line 144, in __init__ > self.descriptor = self.user_prop = descriptor > AttributeError: can't set attribute > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---