58 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Integrating the ORM ...
FromSent OnAttachments
Phillip J. Eby26 Feb 2008 09:18 
sdob...@sistechnology.com26 Feb 2008 10:36 
Michael Bayer26 Feb 2008 11:05 
Phillip J. Eby26 Feb 2008 11:42 
Michael Bayer26 Feb 2008 12:27 
Michael Bayer26 Feb 2008 12:28 
sdob...@sistechnology.com26 Feb 2008 12:35 
sdob...@sistechnology.com26 Feb 2008 13:05 
jason kirtland26 Feb 2008 13:51 
Phillip J. Eby26 Feb 2008 14:27 
Phillip J. Eby26 Feb 2008 14:39 
Michael Bayer26 Feb 2008 14:44 
Michael Bayer26 Feb 2008 16:22 
Phillip J. Eby26 Feb 2008 17:07 
Phillip J. Eby26 Feb 2008 17:30 
Michael Bayer26 Feb 2008 17:39 
sdob...@sistechnology.com26 Feb 2008 22:05 
Michael Bayer26 Feb 2008 23:48 
sdob...@sistechnology.com26 Feb 2008 23:50 
svilen27 Feb 2008 04:58 
Judah De Paula27 Feb 2008 06:46 
Michael Bayer27 Feb 2008 07:22 
Michael Bayer27 Feb 2008 08:58.py
Judah De Paula27 Feb 2008 09:00 
Judah De Paula27 Feb 2008 09:05 
jason kirtland27 Feb 2008 09:19 
Michael Bayer27 Feb 2008 09:40 
Michael Bayer27 Feb 2008 10:06 
Phillip J. Eby27 Feb 2008 12:10 
Michael Bayer27 Feb 2008 13:03 
Michael Bayer27 Feb 2008 13:09 
sdob...@sistechnology.com27 Feb 2008 22:50 
sdob...@sistechnology.com27 Feb 2008 23:20 
Michael Bayer28 Feb 2008 07:18 
Michael Bayer28 Feb 2008 13:16 
Michael Bayer28 Feb 2008 13:19 
sdob...@sistechnology.com28 Feb 2008 13:25 
sdob...@sistechnology.com28 Feb 2008 13:38 
sdob...@sistechnology.com28 Feb 2008 14:15 
Phillip J. Eby28 Feb 2008 14:17 
Phillip J. Eby28 Feb 2008 14:26 
sdob...@sistechnology.com28 Feb 2008 14:37 
Michael Bayer28 Feb 2008 14:41 
Michael Bayer28 Feb 2008 14:48 
sdob...@sistechnology.com28 Feb 2008 15:22 
sdob...@sistechnology.com28 Feb 2008 15:38 
Phillip J. Eby28 Feb 2008 16:15 
Phillip J. Eby28 Feb 2008 16:26 
sdob...@sistechnology.com28 Feb 2008 22:59 
Phillip J. Eby29 Feb 2008 07:38 
Michael Bayer29 Feb 2008 09:55.patch
Phillip J. Eby29 Feb 2008 10:44 
Judah De Paula29 Feb 2008 11:08 
Phillip J. Eby03 Mar 2008 10:38.patch
Michael Bayer03 Mar 2008 11:03 
Phillip J. Eby04 Mar 2008 16:27 
Michael Bayer05 Mar 2008 07:42 
jason kirtland06 Mar 2008 14:41 
Subject:[sqlalchemy] Re: Integrating the ORM with Trellis
From:sdob...@sistechnology.com (sdob@sistechnology.com)
Date:02/26/2008 10:36:31 AM
List:com.googlegroups.sqlalchemy

aah, the dependency-driven processing... i was sure i would have to use trellis one day somehow coupled with a DB, inside my projects... there sooo many dependencies to solve there. Now it might get easier ;-).

Recent year i have done some things like what u need - transparently wrapping SA on declaration side with descriptors et al. On the runtime side (e.g. collections etc), i dont have much. i do have some idea how to do those but not much experience.

on the point: 1. check out dbcook.sf.net/ svn co https://dbcook.svn.sf.net/svnroot/dbcook/trunk 2. check out my static_type library svn co https://dbcook.svn.sf.net/svnroot/dbcook/static_type then, see dbcook/dbcook/usage/static_type/ which concocts both, namely u have staticaly_typed structs/attributes (validation etc) which are also DB-aware i.e. SA-instrumented.

implementation details: i didnot want to overload SA-instrumented descriptors, and i didnot want to copycat all attribute abc as _abc, as this would break one of my goals - not to be able to workaround what have been declared (validation, type etc). All value-access in SA goes via direct __dict__ ... hence i hacked that one. Recently, in 0.4.x i needed to split the value-storage from autoset etc defaultvalue behavior, as SA tracking of changes has evolved. Now the value-storage part is "under" SA, and the autoset behaviour is "above" SA.

yes it looks a bit like a quick and dirty hack, but it works (and i maintain it, more than year already, both 0.4 and 0.3 supported). i didnt have time to niceify it, and i haven't advertised all of it too much as i am sort-of disappointed about how many people are interested in really abstract programming (abstract not in pure mathematical sence, but to be able to "talk" in app.field terms). Anyway, it is there, and i am willing to work together to get something on either side - or a new one.

if this gets too offtopic, u can take it off the list. use either this email or the new az@svilendobrev.com.

ciao svilen dobrev

On Tuesday 26 February 2008 19:18:39 Phillip J. Eby wrote:

Hi folks; I'm trying to figure out how best to integrate SQLAlchemy mappers with Trellis components, so that Trellis applications can use SQLAlchemy in a relatively-transparent way.

The catch is that Trellis components use custom descriptors (like the property builtin, only completely different) so that the Trellis system can see when attributes are read or written, so that inter-component dependencies can be automatically detected, and dependencies automatically updated when values change.

I've been digging through the docs and the sqlalchemy.orm package trying to figure out a clean way to integrate the two, but it appears that the only documented ways to deal with something like this are to either 1) create alternate attributes like '_foo' to be mapped, and then delegate to those attributes from the descriptor, or 2) create an dummy class to which the mapping is applied, and then create linkages between the mapped object and the "real" object.

...and all that's just for the non-collection attributes. I'd really like to use Trellis collections (which also detect and auto-notify their dependencies), too.

Before diving even deeper into this, and possibly end up relying on undocumented aspects of the ORM package for all this, I thought it might be a good idea to see if anybody has any pointers on accomplishing this, especially if there are standard interfaces or things I can subclass to add this stuff in. My ideal outcome would be if I could set things up so that when somebody defines mappings on a Trellis component class, it "just works", even if that means I have to have a whole bunch of logic behind the scenes plugging into SQLAlchemy-supplied hooks.

If that isn't possible, however, I could provide an alternative mapping interface, but I'd still like to be able to have SQLAlchemy returning trellis components, rather than dummy objects that then have to be re-wrapped. (Of course, there's yet another layer of workaround possible, but...)

Anyway, the documentation for the mapping framework seems a bit slim, apart from a few bits about doing collections. I thought I'd check to make sure I'm looking in the right place(s), and check in to see if any of the SQLAlchemy developers have any interest in this sort of integration.

The primary use case for this Trellis-SQLAlchemy integration is database-backed GUI applications that use the Trellis to automatically update displays from model changes, and to update model objects from user input. The Trellis makes this kind of code very simple because it doesn't require explicit publish-subscribe operations; inter-object dependencies are automatically detected, and dependent operations are automatically re-run when their dependencies change.

The specific application that will be used for first, is the experimental re-architecture branch of the Chandler open-source PIM. Right now, there are some simple Trellis-based GUI and model components, that we'd like to hook up to a database backend.

Anyway, if anyone has any pointers, ideas, etc., it would be most helpful. Thanks.