Fw: [Modeling-users] Questions and suggestions
Status: Abandoned
Brought to you by:
sbigaret
From: Ernesto R. <er...@si...> - 2003-06-11 15:16:44
|
Mail I wanted to send to the list instead of sending it directly to Sébastien Erny ----- Original Message ----- From: "Ernesto Revilla" <er...@si...> To: "Sebastien Bigaret" <sbi...@us...> Sent: Tuesday, June 10, 2003 8:09 PM Subject: Re: [Modeling-users] Questions and suggestions Hello again, Inheritance: I'm absolutely astonished. In your example: >>> q = qWQF('toAddresses.zipCode like "4%"') >>> fs = FS('Employee', qualifier=q) >>> fs_deep = FS('Employee', qualifier=q, deepFlag=1) # Note the deepFlag >>> ec.objectsWithFetchSpecification(fs) how this is done at SQL level? Do you execute 3 (one for each subclass of the specified class) SQL queries appending it's result objects to a list? Can you tell us a little bit about your experience, e.g. performance penalties, complications when using inheritance in real world applications? The example you specified (address<<---->employee) is good, could also be: travelling guide, novel, historic novel, etc. to match you book-author example. It would be nice if you could copy and paste it into the inheritance section (quick and dirty), perhaps it could be expanded in the next version. Erny > ----- Original Message ----- > From: "Sebastien Bigaret" <sbi...@us...> > To: "Ernesto Revilla" <er...@si...> > Cc: <mod...@li...> > Sent: Tuesday, June 10, 2003 7:30 PM > Subject: Re: [Modeling-users] Questions and suggestions > > > > Ernesto Revilla <er...@si...> wrote: > > Hi, > > > > for Sebastién: > > * I can only do a comparison matrix with the best-known Python OR-Mappers > > because I haven't done any serious work with them. The major difference is > > that the other ORMs have no query language. In Middlekit, e.g., you can > use > > SQL conditions, but the may not be db-independent. > > Ok. > > > Strange that there is no implementation of OQL. > > Well, it's not *that* known (at least to me;). If you have some good > pointers > for it I'd have a closer look --I've never played with that. > > > To all: > > after working through the docs (v.0.9-pre7) (still didn't try the package) > > here are some > > points: > > > > * Dependencies: The PyPgSQL and PyGreSQL names are interchanged. Also, > > should be pypgsql > > Yes, this has been changed with 0.9pre8 --hopefully this is now okay. If you > find more occurences of such errors, please report again. > > > * What functions are used from 4Suite? (It's 6MB to download for Windows.) > > Isn't it enough to use PyXML? > > Yes it is! 0.9pre8 removed 4Suite from its dependencies --but I forgot to > include that in the announcement. > > > * Installation is a bit complicated, because of the dependencies. What > > chances are there to create a complete install file (perhaps excluding > > db-adaptors) for some of the mile-stone versions? > > There are some chances, if only I could find a script we formerly used to > install the whole stuff. Maybe some of us here still have it at hand? (hey, > these ones know who they are ;) > > > > * Although the inheritance mapping is described, I can't see out of the > docs > > if a relations may map to different tables (say Animals and Humans). This > is > > because the class has to be stored with the foreign key. (See ids.) > > > > About ids and inheritance: > > * Would it be a good idea to specify all object pointers as type ObjectId > in > > the XML-Model file and tell how this is mapped to the DB in the adaptor? > > (integer is enough?) > > > > * May be ObjectIds should be unique throughout the database? (A seperate > > procedure would dispatch new objectids, using some high:low algorithm.) > See > > next point. Also good for replication. > > > > * Either the foreign class (id) has to be stored with each foreign key, or > > the object id contains the class id as part of it (MiddleKit does this). > > > > * How would this be treated in queries? Would a query return objects of > > several tables? (This may require extra queries. A simple INNER JOIN > > wouldn't do it.) > > > > Inheritance makes it real complicated, and in practice, may not be so > > important, depending on the object-model design. > > I'm not sure to fully understand what you mean here, pardon me if my answer > is > off-topic. > > 1. If you're looking for an 'ObjectId', globalID() is for you. A GlobalID > uniquely identifies an object. You can get it with > ec.globalIDForObject(object) > > It answers to: entityName() (mapped to a class in the model) > keyValues (dictionary with pks as keys and their > corresponding values) > > In particular, if two different objects refer to the same row in the > database, they have the same GlobalID. > > 2. Suppose you have the following model: > > Address <<-toAddresses---toEmployee-> Employee > ^ > / \ > T > | > +--------------+ > | | > Executive SalesClerk > > * An address object can be linked to either an Employee, an Executive > or > a SalesClerk instance > > * An address.toEmployee() will retrieve the right object (being an > instances of one of those three classes) > > * when fetching, you can specify whether you want to fetch a single > class or its inheritance tree as well. Compare this, based on the > test > database and model StoreEmployees: > > >>> from StoreEmployees import Address > >>> from Modeling.FetchSpecification import FetchSpecification as FS > >>> from Modeling.EditingContext import EditingContext as EC > >>> from Modeling.Qualifier import qualifierWithQualifierFormat as qWQF > >>> > >>> ec = EC() > >>> q = qWQF('toAddresses.zipCode like "4%"') > >>> fs = FS('Employee', qualifier=q) > >>> fs_deep = FS('Employee', qualifier=q, deepFlag=1) # Note the deepFlag > >>> ec.objectsWithFetchSpecification(fs) > [] > >>> [(o.getFirstName(),o.getLastName()) > ... for o in ec.objectsWithFetchSpecification(fs_deep)] > [('John Jr.', 'Cleese'), ('Jeanne', 'Cleese'), ('John', 'Cleese')] > > > So the answer to your question: > > > * How would this be treated in queries? Would a query return objects of > > several tables? (This may require extra queries. A simple INNER JOIN > > wouldn't do it.) > > is clearly yes! > > However you're right, the documentation lacks even a basic example and > explanantions for this. Does this answers your questions? Feel free to ask > for more. > > -- Sébastien. > > > |