#1139: SQLObject Regression in 1.0b1 from 0.9a8
-----------------------+----------------------------------------------------
Reporter: trlandet | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 1.0
Component: SQLObject | Version: 1.0b1
Severity: critical | Keywords: regression
-----------------------+----------------------------------------------------
I have 3 classes:
{{{
class Base(InheritableSQLObject):
...
class File(SQLObject):
...
class MyClass(Base):
aFile = ForeignKey("File")
otherFile = ForeignKey("File", default=None)
}}}
Note: I have renamed classes etc, but as far as I can see this is the
exact same setup as I have in developement, only with the irrelevant stuff
removed
I then try to create an object:
{{{
object = MyClass(aFile=fileObject1, otherFile=fileObject2)
}}}
This did work in 0.9a8 but fails in 1.0b1 with the following exception
{{{
...
File ".....\SQLObject-0.7.1dev_r1860-
py2.4.egg\sqlobject\inheritance\__init__.py", line 219, in _create
raise TypeError, "%s() did not get expected keyword argument %s" %
(self.__class__.__name__, col.name)
TypeError: MyClass() did not get expected keyword argument aFileID
}}}
The fix is to write:
{{{
object = MyClass(aFileID=fileObject1.id, otherFile=fileObject2)
}}}
And this works as expected, also for otherFile (!) when the only
difference is that otherfile is not a required attribute.
'''Setup notice:'''
Base and !MyClass are in the same .py file but File is in another file. My
model.py looks like this:
{{{
from turbogears.database import PackageHub
from Model import __all__ as dbClasses
from Model import *
hub = PackageHub("turbogearspackage")
__connection__ = hub
# Connect the database classes to the
# database through TurboGears
for c in dbClasses:
# locals contain all local variables, including the imported classes
# Connect all classes to the database defined in the config files
locals()[c]._connection = hub
}}}
SQLObject creates the right (PostgreSQL) tables with foreign key
restraints, !MyClass.sqlmeta.columns has aFile as a foreign reference to
the right table etc.
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1139>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---