On Nov 11, 2010, at 7:50 PM, Sergey V. wrote:
relationship() expects a class or a mapper instance, not a string. I
got this error:
ArgumentError: relationship 'available_deals' expects a class or a
mapper argument (received: type 'str')
Hmm... I'm not sure what I'm doing wrong but
On Nov 12, 6:42 am, Michael Bayer mike...@zzzcomputing.com wrote:
But generally usage of mapper() wasn't intended to provide any tricks
around import issues. You can always use mapper.add_property(...) to attach
things as needed, and class_mapper(Class) to call up any mapper anywhere.
For cases like this I have found something like this to be useful
http://www.sqlalchemy.org/docs/orm/relationships.html#multiple-relationships-against-the-same-parent-child
using lazy loading and viewonly=True as needed
I found this to be clearer than column property because it fits cleanly
relationship() expects a class or a mapper instance, not a string. I
got this error:
ArgumentError: relationship 'available_deals' expects a class or a
mapper argument (received: type 'str')
On Nov 10, 4:46 pm, Sergey V. sergey.volob...@gmail.com wrote:
The twist is that I've spread out my
That is useful for mapping single or combined columns to an attribute.
Here, I want to map entire objects.
On Nov 10, 10:20 pm, Eric Ongerth ericonge...@gmail.com wrote:
Good point, Sergey.
Here is the relevant documentation regarding mapping attributes to
This is what I need to do, except the Merchant object is defined
before the Deal object. In the example in the documentation, I have
mapped User before I have mapped Address.
On Nov 11, 10:25 am, Mike Conley mconl...@gmail.com wrote:
For cases like this I have found something like this to be
If it's simply a matter of sequence of how code is organized:
1. Define Merchants table and mappers
2. Define Deals table and mappers
3. Add relations to Merchant
All of this can be in separate files if needed; just import right
definitions where needed.
metadata = MetaData()
merchants =
relationship() expects a class or a mapper instance, not a string. I
got this error:
ArgumentError: relationship 'available_deals' expects a class or a
mapper argument (received: type 'str')
Hmm... I'm not sure what I'm doing wrong but passing strings to
relation() definitely works for me:
Mike, what you set forth is more of what I was actually trying to
bring into the discussion (having used that same technique myself),
rather than the link I gave above. I need to get more sleep and check
my doc references more carefully!
On Nov 11, 1:39 pm, Mike Conley mconl...@gmail.com wrote:
Hi Jonathan,
Rather than create a specific backref for each subtype of deal, why
not just continue with your basic 'deals' backref, then attach regular
python properties to your Merchant class which return just the desired
sub-deals.
Something like:
class Merchant(object):
...
@property
def
On Nov 10, 12:19 pm, Eric Ongerth ericonge...@gmail.com wrote:
Rather than create a specific backref for each subtype of deal, why
not just continue with your basic 'deals' backref, then attach regular
python properties to your Merchant class which return just the desired
sub-deals.
The twist is that I've spread out my tables and ORM classes across
several files. I've tried to keep it so that I don't have circular
dependencies. That means I've defined Merchant first, and then Deal
later, in separate files
To avoid problems with imports and dependencies you can pass
Good point, Sergey.
Here is the relevant documentation regarding mapping attributes to
selects:
http://www.sqlalchemy.org/docs/orm/mapper_config.html?highlight=arbitrary%20selects#sql-expressions-as-mapped-attributes
On Nov 10, 4:46 pm, Sergey V. sergey.volob...@gmail.com wrote:
The twist is
13 matches
Mail list logo