[storm] Circular reference in defining References.
James Henstridge
james at jamesh.id.au
Wed Sep 2 10:11:43 BST 2009
On Tue, Sep 1, 2009 at 8:14 PM, Mac Ryan<quasipedia at gmail.com> wrote:
> Hello,
>
> I'm experiencing some troubles in defining a Reference from a table to
> another and - simultaneously - a ReferenceSet for the other way around
> relationship.
>
> Using the terminology and examples from the tutorial for clarity, the
> problem is that I cannot include line #1 in the Employee class
> definition unless I have previously defined the class "Company", but I
> can't include #2 in the Company class definition unless I have defined
> the class "Employee" first.
>
> 1. Employee.company = Reference(Employee.company_id, Company.id)
> 2. Company.employees = ReferenceSet(Company.id, Employee.company_id)
>
> Working around this is quite easy (wrapping #1 and #2 into their
> respective __init__ methods, for example), but I would like a word of
> advice on what is the most elegant and clean solution, as each work
> around has its downsides.
The following section of the tutorial probably covers what you're after:
https://storm.canonical.com/Tutorial#The%20Storm%20base%20class
If you derive your classes from the "Storm" base class, you can use
strings in your Reference/ReferenceSet definitions handle forward
references.
James.
More information about the storm
mailing list