[Modeling-cvs] ProjectModeling/Modeling/tests/xmlmodels pymodel_AuthorBooks.py,NONE,1.1 pymodel_Stor
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2004-02-16 20:09:22
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests/xmlmodels In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19962/Modeling/tests/xmlmodels Added Files: pymodel_AuthorBooks.py pymodel_StoreEmployees.py Log Message: Integrated patch #814055: Dynamic creation of packages/modules/classes --- NEW FILE: pymodel_AuthorBooks.py --- #! /usr/bin/env python ''' A sample Pythonic OO-RDB Model (re-expressing testPackages/AuthorBooks/model_AuthorBooks.xml) -- A PyModel must define a global variable called 'model', that is of type Model ''' from Modeling.PyModel import * ## # Set preferred defaults for this model (when different from # standard defaults, or if we want to make things explicit) AFloat.defaults['precision'] = 10 AFloat.defaults['scale'] = 2 AString.defaults['width'] = 40 Association.defaults['delete']=['nullify', 'nullify'] Entity.defaults['properties'] = [ APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK') ] ## _connDict = {'database': 'AUTHOR_BOOKS'} _connDict = {'database': 'AUTHOR_BOOKS', 'host':'localhost','user':'postgres','password':''} model = Model('AuthorBooks',adaptorName='Postgresql', connDict=_connDict) model.doc = ' ... ' model.version='0.1' model.entities = [ # Entity('Book', properties=[ APrimaryKey('id', isClassProperty=1, columnName='id'), AString('title', isRequired=1, columnName='title'), AFloat('price', externalType='NUMERIC', width=0,precision=0), AForeignKey('FK_Writer_Id', isClassProperty=1), ], ), Entity('Writer', properties=[ AString('lastName',isRequired=1, width=30, displayLabel='Last Name', ), AString('firstName', displayLabel='First Name', ), AInteger('age', displayLabel='Age', ), ADateTime('birthday', usedForLocking=0, displayLabel='birthday', ), ] ), ] #--- model.associations=[ Association('Book', 'Writer', relations=['author', 'books'], delete=['nullify', 'cascade'], keys=['FK_Writer_Id', 'id']), Association('Writer', 'Writer', relations=['pygmalion', None], delete=['nullify', None], keys=['FK_Writer_id', 'id']), ] model.build() --- NEW FILE: pymodel_StoreEmployees.py --- #! /usr/bin/env python ''' A sample Pythonic OO-RDB Model (re-expressing testPackages/StoreEmployees/model_StoreEmployees.xml) -- A PyModel must define a global variable called 'model', that is of type Model ''' from Modeling.PyModel import * ## # Set preferred defaults for this model (when different from # standard defaults, or if we want to make things explicit) AFloat.defaults['precision'] = 10 AFloat.defaults['scale'] = 10 AString.defaults['width'] = 30 Association.defaults['delete']=['nullify', 'nullify'] Entity.defaults['properties'] = [ APrimaryKey('id', isClassProperty=0, isRequired=1, doc='Primary key!') ] ## _connDict = {'database': 'STORE_EMPLOYEES'} model = Model('StoreEmployees', adaptorName='', connDict=_connDict) model.doc = ' ... ' model.version='0.1' model.entities = [ # Entity('Store', properties=[ AString('corporateName', isRequired=1), ], ), Entity('Employee', properties=[ AString('lastName',isRequired=1,usedForLocking=1, width=20), AString('firstName', isRequired=1, width=50, usedForLocking=1), ] ), Entity('SalesClerk', parent='Employee', properties=[ AString('storeArea', width=20) ] ), Entity('Executive', parent='Employee', properties=[ AString('officeLocation', width=5) ] ), Entity('Address', properties=[ AString('street', width=80), AString('zipCode', width=10), AString('town'), ] ), Entity('Mark', properties=[ AInteger('month', isRequired=1), AInteger('mark', isRequired=1), ] ), Entity('Holidays', properties=[ ADateTime('startDate', isRequired=1), ADateTime('endDate', isRequired=1), ] ), ] model.associations=[ Association('Mark', 'Executive', relations=['executive', 'marks'], delete=['nullify', 'cascade'], keys=['FK_Executive_id', 'id']), Association('Address', 'Employee', relations=['toEmployee', 'toAddresses'], delete=['deny', 'cascade'], keys=['fkEmployeeId', 'id'], ), Association('Employee', 'Store', relations=['toStore', 'employees'], delete=['nullify', 'deny'], keys=['fkStoreId', 'id']), Association('Holidays', 'Employee', relations=[None, 'holidays'], delete=[None, 'cascade'], keys=['fkEmployeeId', 'id']), ] |