[SQLObject] problems with SQLObject autonaming scheme
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Max I. <ma...@uc...> - 2004-10-21 14:24:09
|
Hi,
I need to setup simple one-to-many relation but has problems due (I
guess) SQLobject's magic autonaming scheme.
Here is my code:
class OrderGateway(SQLObject):
name = StringCol()
prints = MultipleJoin('PrintGateway')
class PrintGateway(SQLObject):
size = StringCol()
order = ForeignKey('OrderGateway')
dborder = OrderGateway(name='me')
print dborder.prints
The last statement gives this error:
psycopg.ProgrammingError: ERROR: column "order_gateway_id" does not exist
I can fix it by renaming column order to order_gateway, but I don't want
to. I also can't rename OrderGateway class to Order class because than I
would get a clash with SQL reserved keyword and anyway, I don't want to
neither. ;-)
I tried to change order's definition to:
order = ForeignKey('OrderGateway', name='order_gateway')
but this gives another error:
Traceback (most recent call last):
File "D:\Python23\Lib\site-packages\sqlobject\main.py", line 70, in
__new__
value.name = attr
File "D:\Python23\lib\site-packages\sqlobject\col.py", line 277, in
_set_name
assert self._name is None, "You cannot change a name after it has
already been set (from %s to %s)" % (self.
_name, value)
AssertionError: You cannot change a name after it has already been set
(from order_gateway to order)
So, any ideas how can I make SQLObject to honor and use the naming
scheme I'm trying to impose on it?
Thanks.
I'm using SQLObject from SVN repository.
|