Re: [Modeling-users] Using modeling framework in long run
Status: Abandoned
Brought to you by:
sbigaret
|
From: Sebastien B. <sbi...@us...> - 2004-07-19 20:17:11
|
John Lenton <jl...@gm...> wrote:
> On 19 Jul 2004 21:00:29 +0200, Sebastien Bigaret wrote:
> >=20
> > Second, the framework does not anymore relies that heavily on code
> > generation, but how could you know since this hasn't been publicly
> > announced yet :/ ... (esp. because it's not fully documented)
>=20
> I'm not clear on one issue: how do I add validators to dynamicly
> created packages?
You add validators, along w/ any necessary business logic, by defining your
own classes. Now I guess the question is how ;)
The simplest way is w/ the metaclass approach, when you declare your
own class with '__metaclass__=3DCustomObjectMeta' (also look at the
sections beginning with <<if __name__ =3D=3D...>> in dynamic.py for
examples)
There is an other solution if you want to stay away from metaclasses,
but it requires more work. For example:
Say you want to have classes in Package.Modules.Classes:
- in your package's __init__.py:
* load the model,
* change its packageName into 'PackageBase' (instead of Package)
* build the classes (either with dynamic.build() or build_with_metaclas=
s())
* revert the model's packageName to its original value 'Package'
- then, define a subclass for each entity, inheriting from
'PackageBase.Module.Class'. They'll inherit from the dynamically
built classes, the framework will use the derived classes which hold
the dedicated validators, etc.
-- S=E9bastien.
> --=20
> John Lenton (jl...@gm...) -- Random fortune:
> bash: fortune: command not found
Hey, keep an eye on your bash, looks like it is trying to escape and
seek fortune ;P
|