Hello!
I'm having some difficulty with inheritance. Specifically, I'm
getting an AttributeError exception at line 348 of inheritance/
__init__.py (in InheritableSQLObject._create()) of SQLObject 0.8.
This happens when I try to instantiate my AND class, which inherits
from a class called Operator. Interestingly, in the DB, Operator's
table has a row, with id=1 and child_name=AND.
Here's the stack trace:
File "/Users/anseljh/pyple/src/pyple.py", line 279, in __main__
andtf = AND(params=[True, False])
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/
declarative.py", line 94, in _wrapper
return fn(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py",
line 1231, in __init__
self._create(id, **kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/SQLObject-0.8.0-py2.4.egg/sqlobject/
inheritance/__init__.py", line 348, in _create
id = self._parent.id
AttributeError: 'Operator' object has no attribute 'id'
Here are the class definitions:
class Operator(InheritableSQLObject):
parameters = MultipleJoin('Parameter')
#def __init__(self, parameters):
def _init(self, *args, **kw):
if DEBUG: print "*"*5, "Start of Operator._init"
if DEBUG: print "*"*5, "I'm a", self.sqlmeta.table
if 'params' in kw:
if DEBUG: print "*"*5, "Handling kw:", kw
if isinstance(kw['params'], types.ListType):
if DEBUG: print "*"*5, "It's a list with", len(kw
['params']), "elements"
for p in kw['params']:
if DEBUG: print "*"*5, "Element:", p
if isinstance(p, Parameter):
if DEBUG: print "*"*5, "It's a Parameter already"
self.add_parameter(p)
else:
if DEBUG: print "*"*5, "Making it a Parameter..."
self.add_parameter(Parameter(value=p))
else:
raise TypeError("params must be a list.")
else:
if DEBUG:
print "*"*5, "No params!"
print "*"*5, "KW:", kw
print "*"*5, "ARGS", args
##self.parameters = parameters
#self.parameters = []
#for p in parameters:
# self.parameters.append(Parameter(value=p))
self.config = {} # misc storage
if DEBUG: print "*"*5, "End of Operator._init"
class AND(Operator):
class sqlmeta:
table = 'op_and'
def eval(self, data):
for param in self.parameters:
if not param.value.eval(data): #
return False #
return True
My full code is at:
http://pyple.svn.sourceforge.net/viewvc/pyple/src/pyple.py?
revision=16&view=markup
Any hints? Am I doing something wrong in my class definitions, or is
this a bug?
Thanks in advance!
-Ansel
P.S. the stack trace also includes a bunch of DeprecationWarnings as
well, shown below:
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py:647:
DeprecationWarning: Use of this attribute should be replaced
with .sqlmeta.addColumn
'.sqlmeta.%s' % self.name, level=self.deprecation_level)
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py:647:
DeprecationWarning: Use of this attribute should be replaced
with .sqlmeta.addIndex
'.sqlmeta.%s' % self.name, level=self.deprecation_level)
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py:647:
DeprecationWarning: Use of this attribute should be replaced
with .sqlmeta.addJoin
'.sqlmeta.%s' % self.name, level=self.deprecation_level)
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py:647:
DeprecationWarning: Use of this attribute should be replaced
with .sqlmeta.delColumn
'.sqlmeta.%s' % self.name, level=self.deprecation_level)
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-
packages/SQLObject-0.8.0-py2.4.egg/sqlobject/main.py:647:
DeprecationWarning: Use of this attribute should be replaced
with .sqlmeta.delJoin
'.sqlmeta.%s' % self.name, level=self.deprecation_level)
-------------------------------------------------------------------------
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