I made a change that should fix this in changeset 1660.
On Jun 23, 2006, at 3:21 PM, Brad Clements wrote: > On 22 Jun 2006 at 23:44, Michael Bayer wrote: > >> a lot has changed with mapper initialization (and plenty of >> bugs....), but not tables. can you send a test example ? > > Sorry my example was not clear. the variable is called 'table' in > my module, but it > is a mapper. > > from P2P.database.dbtables.py: > > --- > > from sqlalchemy import * > from sqlalchemy.mods.threadlocal import * > from sqlalchemy.schema import default_metadata > > metadata = default_metadata > > # table Tregion > # Table of regions > Tregion = Table('region', metadata, > Column('id', > Integer, > primary_key=True, > nullable=False, > ), > Column('name', > String(32), > nullable=False, > ), > ) > > class region(object): > pass > > assign_mapper(region, Tregion) > > -- > > Later, a connection is established via firebird connection.. Then > this (table_name > = 'region'): > > table = table_name and getattr(dbtables, table_name, None) > or None > if not table: > return httpexceptions.HTTPBadRequest(detail="Invalid > tablename %r" % > table_name)(environ, start_response) > > > print "table is %r" % table > print "table.c is %r" % table.c > print "table.c keys %r" % table.c.keys() > > > The output is: > > [2006-06-23 15:12:50,398] [pool] : Connection > <kinterbasdb.Connection object at > 0x0166CE70> checked out from pool > [2006-06-23 15:12:50,398] [engine]: BEGIN > > table is <class 'P2P.database.dbtables.region'> > table.c is <sqlalchemy.orm.mapper.LOrderedProp object at 0x014D4BB0> > table.c keys [] > > [2006-06-23 15:12:50,398] [engine]: ROLLBACK > > (rollback because of exception) > > File 'E:\\prj\\src\\eclipse\\parent_to_parent\\Web\\p2pserver\ > \p2pserver\\dbaccess.py', line 70 in __call__ > args.append(table.c[k] == v) > File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\util.py', line 114 > in __getitem__ > return self.__data[key] > File 'e:\\prj\\src\\sqlalchemy\\lib\\sqlalchemy\\util.py', line 174 > in __getitem__ > return dict.__getitem__(self, key) > exceptions.KeyError: 'id' > > > Now I do a new web request, again: > > table is <class 'P2P.database.dbtables.region'> > table.c is <sqlalchemy.orm.mapper.LOrderedProp object at 0x014D4BB0> > table.c keys [] > > But I take a different path and just do: > > table.select() (that works and returns all rows) > > And then retry the first request: > > [2006-06-23 15:19:44,111] [engine]: BEGIN > table is <class 'P2P.database.dbtables.region'> > table.c is <sqlalchemy.orm.mapper.LOrderedProp object at 0x014D4BB0> > table.c keys ['id', 'name'] > > > So it seems that LOrderdedProp is not being initialized when > table.c.keys() is > accessed, or when table.c['something'] is accessed. > > > > > -- > Brad Clements, [EMAIL PROTECTED] (315)268-1000 > http://www.murkworks.com > AOL-IM or SKYPE: BKClements > > Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users