6 messages in com.googlegroups.pylons-discussI'm lost with ActiveMapper
FromSent OnAttachments
Bruno Silva16 Nov 2006 06:50 
Shannon -jj Behrens16 Nov 2006 11:28 
Bruno Silva16 Nov 2006 14:31 
Alberto Valverde17 Nov 2006 14:13 
Bruno Silva20 Nov 2006 03:04 
Bruno Silva21 Nov 2006 08:34 
Subject:I'm lost with ActiveMapper
From:Bruno Silva (bmsi@public.gmane.org)
Date:11/16/2006 06:50:29 AM
List:com.googlegroups.pylons-discuss

Hi there,

I tried SQLAlchemy and ActiveMapper. And now I'm learning Pylons framework, and I would like to use ActiveMapper. I can' t really tell you how much configurations I tried. I found one that works, but I think perhaps It's not the best practice. I tried to do the connection in every place I could think off, and I always had the error about the engine no bound. So I did the worst case, doing it in the BaseController, and to know if the connection is always made in every request, I simple print a message. What I found is that it prints the message about 10 messages, and then activemapper is always bound. I don't know why that happens, connection pools?

I'm a bit lost here, because I'm new to python/pylons/sqlaclhemy, I hope if someone can point me in the right direction.

thanks in advance, Bruno

----models/__init__.py------- from sqlalchemy import * from sqlalchemy.ext.activemapper import * from datetime import datetime

class User(ActiveMapper): class mapping: __table__ = 'lemmings_sysuser' username = column(String(15)) name = column(String(60)) password = column(String(50)) email = column(String(50)) status = column(Integer) created = column(DateTime) last_login = column(DateTime)

----lib/base.py------- ....... import sqlalchemy.ext.activemapper as activemapper class BaseController(WSGIController): def __call__(self, environ, start_response): if not activemapper.metadata.is_bound(): print "activemapper not bound" from paste.deploy import CONFIG config = CONFIG['app_conf'] dsn = config.get('dsn') if not dsn: raise KeyError('No database uri found!') activemapper.metadata.connect(dsn) return WSGIController.__call__(self, environ, start_response)