I'm trying to establish a "relation" between two tables which have no
PK/FK relation in reality. There is a LOG_EVENTS table with events
comming from all arount the system. I can extract usefull log entries
by the use of NDC (nested diagnostic context) which is really just a
tag attached to number of log events. Table JOBS has a column
LOG_NDC_ID which has the same tag. I'm trying to use those two columns
to establish a relationship but I'm getting:

=========
sqlalchemy\mapping\properties.py in _find_dependent(self)
    261         self.primaryjoin.accept_visitor(visitor)
    262         if dependent[0] is None:
--> 263             raise ArgumentError("cant determine primary foreign
key in the join relationship....specify foreignkey=<column> or
foreignkey=[<columns>]")
    264         else:
    265             self.foreigntable = dependent[0]

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

Here is my attempt:
=========
class Job(ActiveMapper):
    class mapping:
        __table__ = 'jobs'
        id = column(Integer, primary_key = True)
        ...
        description = column(Unicode(250), default=None)
        #log_events = one_to_many("LogEvent") # Gave up on this one

class LogEvent(ActiveMapper):
    class mapping:
        __table__ = 'log_events'
        sort = column(Integer, primary_key = True) # not realy a
primary key, used on rare occassions for sorting
        ...
        ndc_id = column(Integer) # Nested Diagnostic Context
        message = column(Unicode(4000))

Job.mapper.add_property("log_events",
    relation(LogEvent.mapper,
primaryjoin=LogEvent.c.ndc_id==Job.c.log_ndc_id, lazy=True))

Additionally, I was later hoping to extract the messages using
LIMIT/OFFSET, but also have no idea how.
If it can't work like this, I guess I'm just going to make plain Python
property or utility method.

Thanks,
Tvrtko


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to