Re: problem with the simplest of the model

Lorenzo Gil Sanchez <[email protected]> Wed, 29 Sep 2004 12:11:19 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
--=-TEbLF955UUdz/SAdpU0M
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

I wrote a patch yesterday to fix this problem so I'll attach it here for
further review

Lorenzo


El mar, 28-09-2004 a las 12:24 +0200, Lorenzo Gil Sanchez escribió:
> Hello,
> 
> I'm upgrade Modeling with the latest cvs and now, for a very simple
> model, the script mdl_generate_DB_schema.py gives me errors:
> 
> -----------------
> 
> mdl_generate_DB_schema.py -v -C --admin-dsn localhost:pets.sqlite:kk:zz
> model_pets2.py
> Loading the model...
> Error: model has errors:
> 
> Aborting
> 
> ------------------
> 
> As you can see I can't know what is wrong with my model, which I'll
> paste right here:
> 
> 
> from Modeling.PyModel import *
> 
> Entity.defaults['properties'] = [
>     APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK')
>     ]
> 
> model = Model('Pets', adaptorName='SQLite',
>               connDict={'database': 'pets.sqlite'}, version='0.1')
> 
> model.entities = [
>     Entity('Person',
>            properties = [AString('name', isRequired=1)]
>            ),
>     Entity('Animal',
>            properties = [AString('name', isRequired=1)]
>            )
>     ]
> 
> model.build()
> 
-- 
Lorenzo Gil Sanchez <[email protected]>

--=-TEbLF955UUdz/SAdpU0M
Content-Disposition: attachment; filename=db_schema_validation.patch
Content-Type: text/x-patch; name=db_schema_validation.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

Index: ModelValidation.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelValidation.py,v
retrieving revision 1.12
diff -u -r1.12 ModelValidation.py
--- ModelValidation.py	20 Jul 2004 06:21:37 -0000	1.12
+++ ModelValidation.py	28 Sep 2004 11:50:33 -0000
@@ -123,12 +123,12 @@
     return self._dict
   errors=errorsDict
   
-  def has_errors(for_level=None):
+  def has_errors(self, for_level=None):
     """
     """
     if not for_level:
       return not not self._dict
-    if level in self._ignored_levels:
+    if for_level in self._ignored_levels:
       return 0
     for object in self._dict.keys():
       for level in self._dict[object].keys():
Index: scripts/mdl_generate_DB_schema.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/scripts/mdl_generate_DB_schema.py,v
retrieving revision 1.12
diff -u -r1.12 mdl_generate_DB_schema.py
--- scripts/mdl_generate_DB_schema.py	22 Sep 2004 18:56:31 -0000	1.12
+++ scripts/mdl_generate_DB_schema.py	28 Sep 2004 11:50:36 -0000
@@ -351,7 +351,7 @@
   from Modeling.ModelValidation import DEBUG,INFO,WARNING
   errors=MV.ModelValidationException(ignore_levels=[DEBUG,INFO,WARNING])
   MV.validateModel(model, errors)
-  if errors:
+  if errors.has_errors():
     _model_err_log=force_flag and log or err
     if verbose:
         _model_err_log("Error: model has errors:\n"+str(errors))

--=-TEbLF955UUdz/SAdpU0M--



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl