[Zope-dev] Experiments with ORMapping

Shane Hathaway shane@digicool.com
Mon, 14 May 2001 11:47:55 -0400


Chris Withers wrote:
> 
> Shane Hathaway wrote:
> >
> > I'm telling you there's a lot more you can do with the code that makes
> 
> <snip>
> 
> > The next thing to do is to write a fishbowl proposal.
> 
> This sounds cool but made my head hurt :-S
> 
> Can you try and bring this back down to the level of us mere mortals by
> explaining how your OR stuff would let me take a table of data in an RDBMS table
> and have it appear as objects in the Management Inteferace?

Sorry, this is at a pretty low level and I do need to explain it better.

One would define an "ObjectMappingSchema" whose job it is to store and
retrieve objects of a specific type and in a specific location.  It
would usually grab a database connection object to do its work.  When
loading, it would perform a query then manually put attributes into a
persistent object.  When storing, it would grab specific attributes from
the persistent object and execute a statement to store those attributes.

So let's say you want a ZODB to store and retrieve users in a specific
table while putting everything else in pickles.  You would create an
instance of PickleSchema, which implements the ObjectMappingSchema
interface, and tell it to manage everything *except* the users mapping
in BasicUserFolder objects.  You would tell it to store and retrieve
this object using your UserFolderSchema instead.  Your UserFolderSchema
would store and retrieve the users from the USERS and USER_PREFS
tables.  The user table wouldn't require the use of OIDs but would
require unique user IDs.

So in the management interface nothing would change.  Nor would the
application-level Python code.  You would only define a layer that maps
objects to a relational database.  You would still see the user folder
as you do now.

Now, it may be useful to provide a management interface for defining the
schema mapping.  I haven't approached that yet; AFAICT this is where the
work done on SmartObjects and DBObjects would be very useful.  Initially
I was planning for people to code the mapping purely in Python so we
could gain experience and find common patterns before inventing a UI.

Shane