[sqlalchemy] Re: M2M relationship

2008-07-15 Thread Heston James - Cold Beans
Hi Michael, create a file called something like globals.py, and in all other modules that use SQLAlchemy, say import globals. A primer on modules, packages and such is at http://www.python.org/doc/tut/node8.html Excellent! This seems to have done the job, I am now successfully

[sqlalchemy] Re: M2M relationship

2008-07-14 Thread Heston James - Cold Beans
Hi Michael, what I see immediately is that you're declaring mutliple declarative_bases and multiple MetaData objects. All of the Table objects which relate to one another need to share the same underlying MetaData object, and the declarative_base() function also uses a MetaData

[sqlalchemy] Re: M2M relationship

2008-07-14 Thread Heston James - Cold Beans
Hello Michael, what I see immediately is that you're declaring mutliple declarative_bases and multiple MetaData objects. All of the Table objects which relate to one another need to share the same underlying MetaData object, and the declarative_base() function also uses a MetaData

[sqlalchemy] Re: M2M relationship

2008-07-14 Thread Michael Bayer
On Jul 14, 2008, at 11:02 AM, Heston James - Cold Beans wrote: Hello Michael, what I see immediately is that you're declaring mutliple declarative_bases and multiple MetaData objects. All of the Table objects which relate to one another need to share the same underlying MetaData

[sqlalchemy] Re: M2M relationship

2008-07-14 Thread King Simon-NFHD78
Heston wrote: [SNIP] Above you talk about a global module in the application which creates the Base and metadata, but I don't understand how these can then be accessed by other classes around the application? Do you have any good sample code or a link to a decent tutorial? Seems

[sqlalchemy] Re: M2M relationship

2008-07-13 Thread Heston James - Cold Beans
Hi Michael, declarative places a convenience __init__ that installs keywords as attributes, but you're free to override this constructor with anything you'd like. Thank you for confirming this for me, I'd hoped I'd be able to override the class constructor, I often use it for

[sqlalchemy] Re: M2M relationship

2008-07-13 Thread satoru
i'm sorry for my misleading reply;( i was kind of too sleepy last night;P On Jul 13, 5:29 pm, Heston James - Cold Beans [EMAIL PROTECTED] wrote: Hi Michael, declarative places a convenience __init__ that installs keywords as   attributes, but you're free to override this constructor with

[sqlalchemy] Re: M2M relationship

2008-07-13 Thread Heston James - Cold Beans
i'm sorry for my misleading reply;( i was kind of too sleepy last night;P No problem my man. Heston. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: M2M relationship

2008-07-13 Thread Michael Bayer
On Jul 13, 2008, at 5:29 AM, Heston James - Cold Beans wrote: Hi Michael, declarative places a convenience __init__ that installs keywords as attributes, but you're free to override this constructor with anything you'd like. Thank you for confirming this for me, I'd hoped I'd be able

[sqlalchemy] Re: M2M relationship

2008-07-12 Thread satoru
i guess you just shouldn't override the constructor of DeclartiveBase, because it did some keyword args magic inside the constructor. On Jul 12, 12:20 am, Heston James - Cold Beans [EMAIL PROTECTED] wrote: if u look up the stacktrace/traceback, u'll see which statement in your own code

[sqlalchemy] Re: M2M relationship

2008-07-12 Thread Michael Bayer
On Jul 12, 2008, at 8:59 AM, satoru wrote: i guess you just shouldn't override the constructor of DeclartiveBase, because it did some keyword args magic inside the constructor. declarative places a convenience __init__ that installs keywords as attributes, but you're free to override

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread az
NameError's are thrown usualy by import'ing or similar mechanisms. have a look on your code. eventualy post the whole traceback? On Friday 11 July 2008 12:14:12 Heston James - Cold Beans wrote: Good morning all, So, this morning's challenge has been learning many-to-many relationships,

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Heston James - Cold Beans
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

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Michael Bayer
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

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Heston James - Cold Beans
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. Ok this sounds fine, I've done this now, declaring the table in the post.py module. When you

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread az
if u look up the stacktrace/traceback, u'll see which statement in your own code triggered the error. is it in the mapping-part or is still in table-declaration part? do all 3 tables use same metadata? On Friday 11 July 2008 17:31:31 Heston James - Cold Beans wrote: the association table is

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread Heston James - Cold Beans
if u look up the stacktrace/traceback, u'll see which statement in your own code triggered the error. is it in the mapping-part or is still in table-declaration part? do all 3 tables use same metadata? Thank you for your comments so far, I appreciate you helping me out on this. The entire

[sqlalchemy] Re: M2M relationship

2008-07-11 Thread az
i'm not very familiar with declarative but in any way i dont see where u bind a) the metadata to the engine, and b) the declarative-stuff to the metadata. maybe its something i'm missing but maybe read more on those. On Friday 11 July 2008 19:20:21 Heston James - Cold Beans wrote: if u look