Discussion:
[Modeling-users] Bug report with dynamic
Ernesto Revilla
2004-06-25 13:12:01 UTC
Permalink
Dear Sébastien,

going through dynamic, I'm really impressed. (I can learn a lot of stuff
from Modeling.PyModel import Model, Entity, AString
from Modeling import dynamic
m=Model("TheModel")
e=Entity("Person",properties=[AString("name")]
m.entities.append(e)
dynamic.build(m)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\prg\python23\Lib\site-packages\Modeling\dynamic.py", line
153, in build
module_name=model.packageName()
TypeError: 'str' object is not callable

May be this is not a bug? The: m=Model("TheModel") should create an
empty model.

With regards,
Erny
Ernesto Revilla
2004-06-25 13:36:03 UTC
Permalink
In PyModel, line 971: v=apply(v.method, l), the function is evaluated
and substituted by it's value, so:
<function identity at 0x00FD2C70>('name',) will turn into
'TheModel' and this will be stored in object, so packageName is not a
function anymore.

Erny
Post by Ernesto Revilla
Dear Sébastien,
going through dynamic, I'm really impressed. (I can learn a lot of
stuff from you). Although I still did no tests, here what seems a bug
from Modeling.PyModel import Model, Entity, AString
from Modeling import dynamic
m=Model("TheModel")
e=Entity("Person",properties=[AString("name")]
m.entities.append(e)
dynamic.build(m)
File "<interactive input>", line 1, in ?
File "C:\prg\python23\Lib\site-packages\Modeling\dynamic.py", line
153, in build
module_name=model.packageName()
TypeError: 'str' object is not callable
May be this is not a bug? The: m=Model("TheModel") should create an
empty model.
With regards,
Erny
Sebastien Bigaret
2004-06-25 14:08:02 UTC
Permalink
Hi Erny,

Thanks for reporting, the pb. here is that build() does
not accept a PyModel yet. This should be fixed!! Could you please fill a bug
report? Thanks.
Post by Ernesto Revilla
from Modeling.PyModel import Model, Entity, AString
from Modeling import dynamic
m=Model("TheModel") # a PyModel.Model
m.version='0.1' # This is mandatory!!
e=Entity("Person",properties=[AString("name")])
m.entities.append(e)
m.build() # Builds a Model.Model and stores it in 'component'
model=m.component # get the corresponding Model.Model
dynamic.build(model)
import TheModel
TheModel
<module 'TheModel' (built-in)>
Post by Ernesto Revilla
from TheModel import Person
Person
<module 'TheModel.Person' (built-in)>
Post by Ernesto Revilla
from TheModel.Person import Person
Person
<class 'TheModel.Person.Person'>


...given that you apply the included patch ;) which fixes the incorrect way the
modules and classes where represented (as string)

(I'll integrate this into the CVS main trunk)

-- Sébastien.


----------------------------------------------------------
Index: Modeling/dynamic.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/dynamic.py,v
retrieving revision 1.1
diff -u -r1.1 dynamic.py
--- Modeling/dynamic.py 16 Feb 2004 20:01:06 -0000 1.1
+++ Modeling/dynamic.py 25 Jun 2004 16:02:03 -0000
@@ -159,14 +159,14 @@
setattr(m, e.name(),c)
classes[e.name()]=c
modules[e.name()]=m
- m.__name__='AB.'+e.name() # Not required? but in accordance to
observations
+ m.__name__= module_name+'.'+e.name()
add_init(c, e)
add_entityName(c, e)
add_getters(c, e)
add_setters(c, e)
if define_properties:
add_properties(c, e)
-
+ c.__module__=module_name+'.'+e.name()

p=new.module(module_name)
#m.Book=classes['Book']

----------------------------------------------------------
Post by Ernesto Revilla
Dear Sébastien,
going through dynamic, I'm really impressed. (I can learn a lot of stuff
from Modeling.PyModel import Model, Entity, AString
from Modeling import dynamic
m=Model("TheModel")
e=Entity("Person",properties=[AString("name")]
m.entities.append(e)
dynamic.build(m)
File "<interactive input>", line 1, in ?
File "C:\prg\python23\Lib\site-packages\Modeling\dynamic.py", line
153, in build
module_name=model.packageName()
TypeError: 'str' object is not callable
May be this is not a bug? The: m=Model("TheModel") should create an
empty model.
With regards,
Erny
Loading...