Hi,

I've got a setup like this

categories = Table("categories", engine,
                    Column('transaction_id', Integer,
ForeignKey('transactions.id'),
                                  primary_key=True),
                    Column('name', String, primary_key=True))
class Category(object):
   pass
assign_mapper(Category, categories)
transactions = Table("transactions", engine,
                        Column('id', Integer, primary_key=True),
                        Column('recipient', String),
                        Column('amount', Numeric),
                        Column('datetime', DateTime))
class Transaction(object):
   pass
assign_mapper(Transaction, transactions,
                         properties={'categories':relation(Category.mapper)})

With that, Transaction objects have a categories list and I can append
Category objects to it and get Category objects back out and I'm
moderately happy.  I'd be really happy if I could get the categories
list to be a list of strings that represent the name column from
category so I could do

t = Transaction()
t.categories.append('food')#creates a Category with name food and
links it to t.id
objectstore.commit()

and then at some later date do

if 'food' in t.categories:
   #do something depending on the transaction relating to food

and so on.  Essentially, I don't like explicitly dealing with a
Category object when I really just care about one field inside of it.

Is this possible using the mappers or something like that?

Am I trying to do something ridiculous?  I'm new to this whole ORM game.

Thanks,
Charlie


-------------------------------------------------------
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://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to