The sqlalchemy_04_driver requires the SQLAlchemyManager middleware to be set up. This basically involves setting up SQLAlchemy as middleware rather than as part of Pylons as the QuickWiki tutorial does. You can follow the example here:
http://authkit.org/trac/browser/AuthKit/trunk/examples/user/database/app.py Using SQLAlchemyMiddleware isn't the standard way of doing things in Pylons but it is the best way if you want to create middleware services which rely on an SQLAlchemy session. There are other SQLAlchemy Drivers which people have submitted on this list which don't require the middleware. HTH, James keemor wrote: > Hi, > > I'm trying to make QuickWiki Integration Tutorial work with > sqlalchemy_04_driver > http://wiki.pylonshq.com/display/pysbook/Authentication+and+Authorization. > > I changed websetup.py in a way that is not describe in tutorial: > > from authkit.users.sqlalchemy_04_driver import UsersFromDatabase, > setup_model > > def setup_config(command, filename, section, vars): > """Place any commands to setup quickwiki here""" > conf = appconfig('config:' + filename) > load_environment(conf.global_conf, conf.local_conf) > > import quickwiki.model as model > > # Populate the DB on 'paster setup-app' > log.info("Setting up database connectivity...") > engine = config['pylons.g'].sa_engine > > log.info ("Adding users and roles") > setup_model(model, model.metadata) > environ = {} > environ['sqlalchemy.session'] = model.Session > environ['sqlalchemy.model'] = model > > log.info("Creating tables...") > model.metadata.create_all(bind=engine) > log.info("Successfully set up.") > > users = UsersFromDatabase(environ) > users.role_create("delete") > users.user_create("admin", password="opensesame") > users.user_add_role("admin", role="delete") > > log.info("Adding front page data...") > page = model.Page() > page.title = 'FrontPage' > page.content = 'Welcome to the QuickWiki front page.' > > model.Session.save(page) > model.Session.commit() > log.info("Successfully set up.") > > > In development.ini I have: > sqlalchemy.default.url = mysql://root:[EMAIL PROTECTED]/pylons > sqlalchemy.echo = true > > authkit.setup.method = form, cookie > authkit.form.authenticate.user.type = > authkit.users.sqlalchemy_04_driver:UsersFromDatabase > authkit.form.authenticate.user.data = quickwiki.model > authkit.cookie.secret = secret string > > I've taken: > http://authkit.org/svn/AuthKit/trunk/authkit/users/sqlalchemy_04_driver.py > > When I call: > paster setup-app development.ini > > Everything is all right and proper changes in database are made. > > But when I call: > paster serve --reload development.ini > > File "/usr/lib/python2.5/site-packages/AuthKit-0.4.0-py2.5.egg/ > authkit/authenticate/form.py", line 131, in make_form_handler > prefix='authkit.method.form', > File "/usr/lib/python2.5/site-packages/AuthKit-0.4.0-py2.5.egg/ > authkit/authenticate/form.py", line 114, in load_form_config > format='basic' > File "/usr/lib/python2.5/site-packages/AuthKit-0.4.0-py2.5.egg/ > authkit/authenticate/__init__.py", line 191, in > get_authenticate_function > users = user_object(user_conf['data'], encrypt) > File "/usr/lib/python2.5/site-packages/AuthKit-0.4.0-py2.5.egg/ > authkit/users/sqlalchemy_04_driver.py", line 100, in __init__ > if not environ.has_key('sqlalchemy.model') or not > environ.has_key('sqlalchemy.session'): > AttributeError: 'str' object has no attribute 'has_key' > > If I use files instead of db in development.ini everything works just > fine: > authkit.form.authenticate.user.type = authkit.users:UsersFromFile > authkit.form.authenticate.user.data = /home/keemor/pylons/ > users_information.txt > > I think I've digged everything about it, so please give me a clue. > > Greetz > -- > keemor > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---