Phillip J. Eby wrote:
> At 12:02 PM 3/27/2008 -0700, jason kirtland wrote:
> 
>> Phillip J. Eby wrote:
>>> I just noticed that in the latest version of the branch, there's a
>>> new_instance() call that is using a class' __new__ method in order to
>>> create a new instance, rather than using 'class()'.  What I'd like to
>>> find out is how to get around this, because Trellis objects will not
>>> be properly initialized unless the 'class()' is called, with any
>>> initialization taking place inside __new__ and/or __init__.   Trellis
>>> doesn't override __new__ or __init__, and doesn't care what they
>>> do.  But the creation of an instance *must* be wrapped by the class'
>>> __call__ (i.e. class()), as there is a try/finally involved that 
>> must execute.
>>> Any thoughts on how this might be refactored?  What is 
>> new_instance() used for?
>>
>> new_instance creates an instance without invoking __init__.  The ORM
>> uses it to recreate instances when loading from the database.
>> new_instance can be added to InstrumentationManager as an extension
>> method... The ORM doesn't care how empty instances are manufactured so
>> long as they can be created without initialization arguments, e.g. a
>> no-arg constructor.
> 
> Does that mean that no attributes must be set from new_instance(), either?

You should be able to set whatever you like there.

> On a separate note, I noticed that the class manager machinery 
> allowed one to just directly subclass ClassManager instead of making 
> an InstrumentationManager.  Was that intentional?  I preserved this 
> behavior when I corrected the staticmethod failure problem, but the 
> tests don't appear to test for that.

Yes, that's an intentional capability.  I'm actively refactoring the 
entire mechanism to work in the MapperExtension-driven instrumentation 
election that's desired for the Zope security proxy integration; 
covering tests will be committed shortly as the whole starts to take a 
usable shape.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to