hmm strange, i tried this out with sqlalchemy version 0.4.1 but it
does not seem to work...

>>> s.name
u'HALN01100601'
>>> isinstance(s.name, sqlalchemy.orm.PropertyLoader)
False
>>> s.targets
[<tcd_sample_database.model.samples.Target object at 0xb608dcac>]
>>> isinstance(s.targets, sqlalchemy.orm.PropertyLoader)
False

both attributes were loaded by sqlalchemy. also,

>>> getattr(s.materials, "direction")
Traceback (most recent call last):
  File "<console>", line 1, in ?
AttributeError: 'InstrumentedList' object has no attribute 'direction'

is this implemented in sqlalchemy 5?

brendan




On Dec 3, 2007 9:30 PM, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
> id look at prop = MyClass.someattribute.property, use isinstance(prop,
> PropertyLoader) to determine a relation and not a scalar, combined
> with getattr(prop, "direction") == sqlalchemy.orm.sync.MANYTOMANY,
> ONETOMANY, etc. to get the type of join.
>
>
> On Dec 3, 2007, at 3:43 PM, Brendan Arnold wrote:
>
> >
> > hi there,
> >
> > i'd like a way to determine if an attribute of an orm object is:
> >
> >    a:) a sqlalchemy generated list of objects (i.e. many-to-many)
> >    b:) a single sqlalchemy joined object (i.e.one-to-many)
> >    c:) a 'scalar' loaded from the database (i.e. a string, float,
> > integer)
> >
> > at present i'm copying the text generated by
> > 'type(orm_obj.joined_list)' to determine a: and a 'type(float, int
> > etc.)' for c:, whats left is b.
> >
> > this seems shakey, is there a better way? are there some 'types'
> > defined in sqlalchemy?
> >
> > brendan
> >
> > >
>
>
> >
>

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