Sorry to bother you, but in both of my emails I had a feeling there was something else aside from my ignorance and I was hoping maybe we could even squash a bug or two if there are any.

P.S. By the way, I just noticed Gmail did not Reply to all.

On 3/14/06, Qvx 3000 <[EMAIL PROTECTED]> wrote:
I didn't use foreign key because it really isn't a FK. Many other objects could contain the same kind of tag which is then used to extract the messages. Think of it like you have a set of messages and you can group them into subsets using this tag. One subset belongs to a job instance (my example). The other subset belongs to some other procedure which used logging facility to leave a trace of its execution (each message was tagged with id which is unique to some specific invocation of the function). And so on. So potentially, I have a case where LogEvent.NDC_ID points to dozen of tables and in some cases to no table at all.

I guess my problem was because I tried to use add_property. I used add_property because using ActiveMapper doesn't allow me to construct mapper the way I can manually, or I don't know how. Consider this example:

from sqlalchemy import *
engine = create_engine('sqlite://filename=:memory:', echo=True)

job_table = Table('job', engine,
    Column('id',  Integer, primary_key=True),
    Column('log_ndc_id', Integer),
    Column('name', Unicode(50)))
job_table.create()

event_table = Table('event', engine,
    Column('not_realy_pk', Integer, primary_key=True),
    Column('ndc_id', Integer),
    Column('message', Unicode(2000)))
event_table.create()

class Job(object): pass
class Event(object): pass
Event.mapper = mapper(Event, event_table)

# This works:
Job.mapper = mapper(Job, job_table, propertied = dict(
    events = relation( Event.mapper, primaryjoin = job_table.c.log_ndc_id==event_table.c.ndc_id)))

# But the following doesn't work:
Job.mapper = mapper(Job, job_table)
Job.mapper.add_property('events_late', relation(Event.mapper, primaryjoin = job_table.c.log_ndc_id==event_table.c.ndc_id))


ArgumentError: cant determine primary foreign key in the join relationship....specify foreignkey=<column> or foreignkey=[<columns>]

Reply via email to