I'm having a couple of problems with getting intermediate tables working
in the attached script. The problems are:
1. When the script is run, neither the pw_product_forecast nor the
pw_purchase_map tables are created. However, pw_forecast_resolution
(the other related join) is created.
2. If I change the name of the "Forecast" class to "ProductForecast",
the pw_product_forecast table is created. However, there is no
"addForecast" method available on Product. If I change the name of the
field in Product to "productForecasts", an "addProductForecast" method
is available.
There seems to be a problem with the alphabetical ordering of these
table/field names. Any pointers as to what I can do to fix this would
be greatly appreciated. I'm using SQLObject 0.7.2 on MySQL 4.1.15.
Cheers
Peter
from sqlobject import *
CONNECTION_URI = 'mysql://user:[EMAIL PROTECTED]/database'
sqlhub.processConnection = connectionForURI(CONNECTION_URI)
sqlhub.processConnection.debug = 0
class Registration(SQLObject):
class sqlmeta:
table = 'pw_registration'
firstName = StringCol(length=50, default='peter')
lastName = StringCol(length=50)
email = StringCol(length=80)
password = StringCol(length=50, default=None)
purchases = MultipleJoin('Purchase')
class Purchase(SQLObject):
class sqlmeta:
table = 'pw_purchase'
purchaseDateTime = DateTimeCol()
modifiedDateTime = DateTimeCol()
registration = ForeignKey('Registration')
product = ForeignKey('Product')
maps = RelatedJoin('Map', intermediateTable='pw_purchase_map')
class Product(SQLObject):
class sqlmeta:
table = 'pw_product'
name = StringCol(length=80)
description = StringCol()
forecasts = RelatedJoin('Forecast', intermediateTable='pw_product_forecast')
class Forecast(SQLObject):
class sqlmeta:
table = 'pw_forecast'
name = StringCol(length=80)
description = StringCol()
resolutions = RelatedJoin('Resolution', intermediateTable='pw_forecast_resolution')
class Resolution(SQLObject):
class sqlmeta:
table = 'pw_resolution'
name = StringCol(length=20)
resolution = IntCol()
class Map(SQLObject):
class sqlmeta:
table = 'pw_map'
name = StringCol(length=80)
parent = ForeignKey('Map')
areas = MultipleJoin('MapArea', joinColumn='map_id')
resolution = ForeignKey('Resolution')
class MapArea(SQLObject):
class sqlmeta:
table = 'pw_map_area'
name = StringCol(length=80)
x = IntCol()
y = IntCol()
width = IntCol()
height = IntCol()
linkedMap = ForeignKey('Map')
map = ForeignKey('Map')
CLASSES = [Registration, Product, Forecast, Resolution, Map, MapArea, Purchase]
def create():
for cl in CLASSES:
cl.createTable()
def drop():
for cl in CLASSES:
cl.dropTable(ifExists=True)
if __name__ == '__main__':
drop()
create()
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss