[sqlalchemy] Re: plain python objects from ORM

2007-09-25 Thread Michael Bayer


On Sep 24, 2007, at 10:43 PM, Huy Do wrote:


 Michael Bayer wrote:
 On Sep 24, 2007, at 11:48 AM, Huy Do wrote:


 Hi,

 Is it possible to get SA ORM to return plain python objects (with
 eagerloaded relations and all) but without any attribute
 instrumentation
 (or anything else magically added by SA).




 not really.   unless you remove the instrumentation from the classes
 themselves afterwards (a one way operation).

 Any pointers on how to do this ? to the whole object hierachy.

clear_mappers()

 of course you could argue that theres no technical reason the ORM
 shouldnt be able to do this.  there could be some extremely
 specialized rewrite of attributes.py that could do it perhaps, but
 maintaining test coverage for that would be a whole project in itself
 Would a mapper extension allow me to do this ?

not really.


 I think this would be a great feature to have because there are  
 many use
 cases in my application (mainly displaying/processing tables) where I
 don't want/need the overhead of the instrumentation (and it really  
 does
 add quite a bit), but would still love the excellent mapping abilities
 (i.e have fully hydrated domain objects rather then ResultProxy).

I think theres still going to be a lot of overhead even without  
instrumentation.  anyway, this would be an enormous amount of effort  
to establish and also to keep test coverage going, and would probably  
be a significant complication to the internals.  Id rather focus on  
making our current, single approach faster and better (note that 0.4  
uses about half the method call overhead of 0.3 for load operations).

If you want, just create a rudimentary object creation layer over the  
normal SQL constructs.  It would be more appropriate for this to be  
something entirely separate from the existing orm module.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: plain python objects from ORM

2007-09-25 Thread Huy Do


 I think this would be a great feature to have because there are  
 many use
 cases in my application (mainly displaying/processing tables) where I
 don't want/need the overhead of the instrumentation (and it really  
 does
 add quite a bit), but would still love the excellent mapping abilities
 (i.e have fully hydrated domain objects rather then ResultProxy).
 

 I think theres still going to be a lot of overhead even without  
 instrumentation.  anyway, this would be an enormous amount of effort  
 to establish and also to keep test coverage going, and would probably  
 be a significant complication to the internals.  Id rather focus on  
 making our current, single approach faster and better (note that 0.4  
 uses about half the method call overhead of 0.3 for load operations).
   
fair enough. I think I'm just a big fan of the ORM load features, but 
not of the (cascading) flush (save/update/delete) features. I am a 
control freak when it comes to the database. There was a stage when I 
did not like the sql generated from the ORM load as well, but recently 
(not sure which version) the sql it generates is almost ;-) as good as 
the one i write by hand

 If you want, just create a rudimentary object creation layer over the  
 normal SQL constructs.  It would be more appropriate for this to be  
 something entirely separate from the existing orm module.
   
I was thinking along these lines. I am going to study your 
query.instances to get some hints

Thanks for all the help.

Huy


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: plain python objects from ORM

2007-09-24 Thread Michael Bayer


On Sep 24, 2007, at 11:48 AM, Huy Do wrote:


 Hi,

 Is it possible to get SA ORM to return plain python objects (with
 eagerloaded relations and all) but without any attribute  
 instrumentation
 (or anything else magically added by SA).



not really.   unless you remove the instrumentation from the classes  
themselves afterwards (a one way operation).

of course you could argue that theres no technical reason the ORM  
shouldnt be able to do this.  there could be some extremely  
specialized rewrite of attributes.py that could do it perhaps, but  
maintaining test coverage for that would be a whole project in itself.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: plain python objects from ORM

2007-09-24 Thread Huy Do

Michael Bayer wrote:
 On Sep 24, 2007, at 11:48 AM, Huy Do wrote:

   
 Hi,

 Is it possible to get SA ORM to return plain python objects (with
 eagerloaded relations and all) but without any attribute  
 instrumentation
 (or anything else magically added by SA).

 


 not really.   unless you remove the instrumentation from the classes  
 themselves afterwards (a one way operation).
   
Any pointers on how to do this ? to the whole object hierachy.
 of course you could argue that theres no technical reason the ORM  
 shouldnt be able to do this.  there could be some extremely  
 specialized rewrite of attributes.py that could do it perhaps, but  
 maintaining test coverage for that would be a whole project in itself
Would a mapper extension allow me to do this ?

I think this would be a great feature to have because there are many use 
cases in my application (mainly displaying/processing tables) where I 
don't want/need the overhead of the instrumentation (and it really does 
add quite a bit), but would still love the excellent mapping abilities 
(i.e have fully hydrated domain objects rather then ResultProxy).


Thanks

Huy

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: plain python objects from ORM

2007-09-24 Thread sdobrev

On Tuesday 25 September 2007 05:43:40 Huy Do wrote:
 Michael Bayer wrote:
  On Sep 24, 2007, at 11:48 AM, Huy Do wrote:
  Hi,
 
  Is it possible to get SA ORM to return plain python objects
  (with eagerloaded relations and all) but without any attribute
  instrumentation
  (or anything else magically added by SA).
 
  not really.   unless you remove the instrumentation from the
  classes themselves afterwards (a one way operation).

 Any pointers on how to do this ? to the whole object hierachy.
just grab the objects __dict__, and make any class out of it. u'll 
need 2 parralel class hierarchies, or maybe one parasit hierarhcy 
hanging on the other..
e.g.
class Aplain:
 methods...
 def undress(self): 
r = self.__class__(); r.__dict__.update( self.__dict__); return r
class Aplain4SA(Aplain): pass
m = mapper( Aplain4SA, ...)
...

def myquery( query):
 for q in query: yield q.undress()

and use myquery() as wrapper for all session.query(..)
the overhead would be one generator..

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---