On Jul 11, 2008, at 9:59 AM, Heston James - Cold Beans wrote:

> > NameError's are thrown usualy by import'ing or similar mechanisms.
> > have a look on your code.
> > eventualy post the whole traceback?
>
> Hello Mate,
>
> I think you’re right, but the problem is that I don’t know what I  
> ‘should’ be importing into the class. See, I have two files; Post.py  
> and Keyword.py, both of which contain a single class of the same name.
>
> I want to form a M2M relationship between them. If I want to declare  
> a relationship in Post.py do I have to import Keyword.py? and what  
> about the joining/association table? Do I need to create a class  
> which represents that too?
>

the association table is an instance of Table, and does not need its  
own class.   It's easiest to declare the association table in the same  
module as that which it is used, in this case "post.py".

When you create "post.py", that creates Post, and in order to create  
the relation either needs to import "keyword.py" directly, or, when a  
third module uses "post.py" it would have to also import "keyword.py"  
before using the Post class.

Basiclally nothing happens until the classes are first used.    When  
the classes are first used, all dependencies must have been imported  
at some point.  It doesn't matter from where since they are all  
ultimately placing themselves in a SQLAlchemy-specific registry.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to