Re: [Modeling-users] Bug report with dynamic
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2004-06-25 16:07:27
|
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. Now in the meantime you can have it work this way: >>> 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)> >>> from TheModel import Person >>> Person <module 'TheModel.Person' (built-in)> >>> 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'] ---------------------------------------------------------- Ernesto Revilla <er...@si...> wrote: > 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 to me: > > When I do the following, I get an error (CVS version): > > >>> 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 > > > > > |