up0 wrote: > I'm ready to move on to pylons/myghty (after quite a bit of working > with Django and other webframework) but I'm stuck on this. How do I > use SQLAlchemy with it? In "models/__init__.py", uncommenting few > lines seem to make it work with SQLObject. But is there any example > for SQLAlchemy? > > Any help would be appreciated.
Apart from an example Ben Bangert posted to the list a while back wrt pagination (http://groups.google.com/group/pylons-discuss/browse_thread/thread/b43fe4563c93bbc/3a174f5f1ae968b2?q=sqlalchemy&rnum=1#3a174f5f1ae968b2), I'm not aware of any other SQLAlchemy specific examples. Have a look at how that example sets things up, using __init__.py for the classes that will be mapped to the tables (specified in tables.py). Ben added 'contentstor' to handle the actual mapping (and the validation using FormEncode), but one of the features of SA is that there are a number of ways to do things depending on your particular requirements/environment. I've tended to follow the setup that Mike Bayer used in his Myghty zblog example which is to keep the database/ORM specific code separate from the domain classes (see http://www.myghty.org/trac/wiki/ZblogReadme), as for one thing, it helps me to focus on whether the functionality I'm building really should be in the database classes and is not better done in the domain, with some db helpers for example. To do this in pylons add a 'database' and 'domain' module to models, put your tables.py and mappings.py in 'database' and the domain classes in (surprisingly) the 'domain' module. You can setup the mappings in models/__init__.py or in lib/app_globals.py (which is where I do it - mainly due to a requirement to be able to run against any number of historical datasets in different databases/clusters). HTH Robert --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
