[TransWarp] model.Attribute questions
Ulrich Eck
ueck at net-labs.de
Tue Mar 25 04:02:24 EST 2003
Hi Radek,
we've worked on a SQLEntityDM that is configurable with
- Column <-> Feature Map
- Indexes
- Sequences (no MySQL Autoincrement)
it is tested with SAPDB SQL-Database and has
an OR-Mapping for sapdb-sqlschema with some sqlschema2model
script that creates Element-, EntityDM- and QueryDM classes.
You might find it usefull .. we'ld be happy to share work and ideas
on our stuff. you can find it at:
http://cvs.net-labs.de -> apps/nll/src/nll/database/ ...
cvs -d:pserver:anonymous at cvs.net-labs.de:/data/cvs login
passwd: anonymous
cvs -d:pserver:anonymous at cvs.net-labs.de:/data/cvs co apps/nll
there is no setup.py yet .. so you can use pyenv.sh to add the lib to
the python-path.
cu Ulrich Eck
Am Montag, 24. März 2003 21:31 schrieb Radek Kanovsky:
> Hi,
>
> I have found PEAK features very useful and decided to use it for the
> first time in my application. One of my goals is to bother less with SQL
> because designing in Python and SQL together is often very uncomfortable
> and doubles work. I have started to code SQLEntityDM with infrastructure
> for making SQL data definition and data manipulation more pythonic
> way. Automatic creation of database tables from model.Elements seems
> relatively easy and straightforward but anyway I am not able to catch
> some basics:
>
> class Book (model.Element) :
>
> class Title (model.Attribute) :
> referencedType = model.String
>
> class Pages (model.Attribute) :
> referencedType = model.Integer
>
> * Is there a standard PEAK way for defining maximum length of Book.Title
> value? I want to generate appropriate VARCHAR(<N>). I think that attributes
> model.String.length or model.Atribute.upperBound are for other purposes.
> Same question arises about UNIQUE, NOT NULL, etc.
>
> * Why doesn't peak check values assigned to element attributes? Do I need
> to make it manualy as follows?
>
> class Title (model.Attribute) :
> referencedType = model.String
> def set (attrcls, obj, val) :
> val = str(val) # need string
> if length(val) > 100 :
> raise ValueError('Nobody reads such long titles')
> return super(attrcls, attrcls).set(obj, val)
>
> class Pages (model.Attribute) :
> referencedType = model.Integer
> def set (attrcls, obj, val) :
> val = int(val) # need int
> if val < 0 : raise ValueError("Antibook!!!")
> return super(attrcls, attrcls).set(obj, val)
>
> Or methods storage.EntityDM.(_new|_save) are the right place for doing
> such things? But this relates naturaly to model and not to storage.
> I must confess that I am slightly confused by contents of
> model/datatypes.py file and its purpose.
>
> Thanks.
>
> Radek
>
>
> PS: I think that there is typo in model.datatypes.Double that parent
> of Double should be Float and not PrimitiveType. Python float
> is defined as double at C level so it is able to hold both
> float and double values.
>
> class Float(PrimitiveType):
> mdl_fromString = float
>
> class Double(PrimitiveType):
> pass
> _______________________________________________
> TransWarp mailing list
> TransWarp at eby-sarna.com
> http://www.eby-sarna.com/mailman/listinfo/transwarp
More information about the PEAK
mailing list