On Dec 19, 2008, at 15:36, percious <[email protected]> wrote:

>
> Yes, and I am doing that.
>
> The problem becomes when you have two models that have the same named
> classes.

How is that? AFAIK, as long as they're declared in different modules,  
two classes with the same name are different objects altogether.

>  I check to make sure the mapper points to the proper
> metadata before returning the class.
>
> Question:  why is it ok to bind the DBSession, and not the metadata?
> This seems contradictory in my mind.

As Mark has pointed out in this thread, the session is thread-local  
(ie: can be configured dynamically on a per-request basis which can be  
very useful in some situations) while the metadata has a module scope  
(process scope) which makes some advanced use-cases impossible.

>
>
> In case anyone is wondering, DBSprockets need the ability to query the
> database so it can fill in the proper data for the drop-down menus, as
> well as to fill in table data.

Can't it query it with the good old
DBSession.query(SomeClass)
?

Alberto

>
> cheers.
> -chris
>
> On Dec 19, 1:29 am, Alberto Valverde <[email protected]> wrote:
>> percious wrote:
>>> So, I did some experimentation tonight using the engine as an
>>> identifier.
>>
>>> The problem is that I have no way of knowing which class is mapped  
>>> to
>>> which engine without binding them.  Maybe I'm missing something
>>> here...
>>
>> from sqlalchemy import orm
>> mapper = orm.class_mapper(MyClass)
>> # introspect the mapper...
>>
>> This is how RumAlchemy gets information about a mapped class'  
>> properties:http://toscawidgets.org/hg/RumAlchemy/file/tip/rumalchemy/util.py
>>
>> IIRC, you don't *need* a connection to a database (engine) to  
>> introspect
>> the mapper. For CRUD operations you just need a reference to  
>> DBSession
>> so you can create Query objects from a mapped class. You can safely
>> assume that DBSession has already been bound to an engine somehow I  
>> guess.
>>
>> Alberto
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to