James Gardner wrote: > Hi all, > > Thanks for the many comments about the QuickWiki tutorial. I've updated > it with the following changes: > > * SQLAlchemy SessionContext rather than threadlocal
[...] > The new version of the tutorial is here: > http://pylonshq.com/project/pylonshq/browser/Pylons/trunk/docs/quick_wiki.txt?rev=1421 I was able to make modifications the code to have tables and classes together in the different file than "models/__init__.py". So for people don't wanting all their table/class in the same "models/__init__.py" file and wanting to organize and separate each table/class objects in different files, here's how I made it: Create a new "models/pages.py" and write your SA tables/classes and map them together as followed: ***** models/pages.py ***** from sqlalchemy import * from __init__ import metadata __all__ = ["Page", "metadata"] # Would the mapper and table be needed? pages_table = Table('pages', meta, Column('title', String(40), primary_key=True), Column('content', String(), default='') ) class Page(object): def __str__(self): return self.title page_mapper = mapper(Page, pages_table) *************************** ***** models/__init__.py ***** from sqlalchemy import * meta = DynamicMetaData() # This will only import in the namespace what's in "__all__". from pages import * ****************************** I'm not sure this might be the "correct" way to do it, but it works for me. :) ps: Joe, I agree with you, it's nicer to have SA tables and classes together in the same file rather than having "tables.py" and "models.py" files. Regards, -- Alexandre CONRAD --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss -~----------~----~----~----~------~----~------~--~---
