is this a bug in modeling?
John Lenton <[email protected]> Mon, 23 Aug 2004 10:50:27 -0300
| Newsgroups | gmane.comp.python.modeling |
|---|---|
| Message-ID | <[email protected]> |
Hi all.
I've been owing you this for a while now.
The attached model, with Modeling 0.9-pre16 + sortBy/limit patch, and
0.9-pre17.1 + sortBy/limit + quoted entities patch, produces the same
(bad?) behaviour. I can test it with a plain 0.9-pre17.1 if you think
it's needed.
The behaviour is this: when an attribute is requested on a fault that
stands in for an object that is a subclass of the target of the
relation, and that attribute isn't present in the base class, an
exception is raised. Thus:
>>> from Modeling.EditingContext import EditingContext
>>> ec=EditingContext()
>>> import Store
>>> p=ec.fetch('Address')[0].getPerson()
>>> p.isFault()
True
>>> p.getTag()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: Person instance has no attribute 'getTag'
>>> p.getId()
1
>>> p.isFault()
False
>>> p.getTag()
'foo'
>>>
--
John Lenton ([email protected]) -- Random fortune:
The greatest of faults is to be conscious of none.
model.py
(text/x-python, 926 B)
from Modeling.PyModel import *
# Defaults
AString.defaults['width'] = 40
Entity.defaults['properties'] = [
APrimaryKey('id', isClassProperty=1, isRequired=1, doc='PK')
]
#Description Data sources
dataSource = {'database': 'store', 'host': 'localhost',
'user': 'john', 'password': '',
}
model = Model('Store',
adaptorName='Postgresql',
connDict = dataSource,
version = '0.1',
)
# entidades del modelo
model.entities = [
Entity('Person'),
Entity('Employee', parent = 'Person',
properties = [AString('Tag'),],
),
Entity('Address'),
]
# asociaciones del modelo
model.associations =[
Association('Address','Person',
relations=['Person','Address'],
delete=['nullify','deny'],
),
]