Shuo Yang wrote:
> I modified the code to be this:
>
> output_place = place.alias('output_place')
> input_place = place.alias('input_place')
>
> Place.mapper = mapper(Place, place)
> Transition.mapper = mapper(Transition, transition, properties = dict(
>         inputs = relation(Place, output_place, place_output, lazy=False),
>         outputs = relation(Place, input_place, place_input, lazy=False),
>         )
>     )
>
> Now if I run it, there is an attribute error:
>
> ...
> AttributeError: 'Alias' object has no attribute 'foreign_keys'
>

OK thats a straight up bug on my part.

first, try this patch, to stick a reasonable foreign_keys attribute onto
Alias:

--- sql.py      30 Nov 2005 21:05:08 -0000      1.1.1.1
+++ sql.py      30 Nov 2005 21:59:00 -0000
@@ -672,6 +672,7 @@

     primary_keys = property (lambda self: [c for c in self.columns if
c.primary_key])

+    foreign_keys = property(lambda s: s.selectable.foreign_keys)
     def hash_key(self):
         return "Alias(%s, %s)" % (repr(self.selectable.hash_key()),
repr(self.name))


then if that doesnt work, you can also say:

    Transition.mapper = mapper(Transition, transition, properties = dict(
         inputs = relation(Place, output_place, place_output,
primaryjoin=and_(output_place.c.foo==place_output.c.foo,
          place.c.bar==place_output.c.bar)
lazy=False),
          ...


The state of this thing is, the structure to support all the operations is
there, its just a lot of it only works in the most verbose fashion so
far....


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to