OK I've made some progress. Previously I had simply copied sqlalchemy_04_driver.py into my existing authkit 0.4 directory. It ocurred to me that maybe that wasn't the way to do it. I checked out the latest AuthKit from SVN, edited setup.py to use setuptools, and installed the egg. That resolved the exception I was reporting previously.
Now websetup.py works, I can successfully add users/roles etc. I did have to tweak the example code somewhat, and I'm still not happy with the way it's setting up the environ variable explicitly, isn't that supposed to be in app_conf or something? Actual authentication ALMOST works but not quite. When I go to a protected controller, AuthKit displays the sign in page correctly, but when I submit my info it redirects to a crazy URL. I've created a controller called "auth" with a method called "private" that is protected by an @authorize decorator. When I load "http:// localhost:5000/auth/private" in my browser, I see the AuthKit sign in form. When I enter info and click submit, regardless of what info I enter, I am redirected to this URL: "http://localhost:5000/auth/:// localhosthttps://localhost:5000/auth/private". There's something screwy going on around here... On Feb 13, 1:33 pm, n1ywb <[EMAIL PROTECTED]> wrote: > Hi James, > > I followed the given example and I'm getting "AttributeError: 'str' > object has no attribute 'has_key'" but when I try to set up the > authkit middleware in middleware.py. > > It might be helpful if you could develop an sqlalchemy_04_driver > example that actually uses Pylons... > > In a slight aside, is there any reason why I can't use your > SQLAlchemyManager thing for AuthKit and use a normal session for my > own stuff at the same time? > > Here's what I have: > > # middleware.py > from authkit.users import sqlalchemy_04_driver > import authkit.authenticate > > from authtest.model import setup_model > from sqlalchemymanager import SQLAlchemyManager > ... > # AuthKit > app = SQLAlchemyManager(app, app_conf, [setup_model, > sqlalchemy_04_driver.setup_model]) > app = authkit.authenticate.middleware(app, app_conf) > ... > > # development.ini > ... > # sqlalchemy bitches if I use default.url > #sqlalchemy.default.url = sqlite:///%(here)s/quickwiki.db > sqlalchemy.url = sqlite:///%(here)s/quickwiki.db > > authkit.setup.method = form, cookie > authkit.cookie.secret = secret string > authkit.cookie.signoutpath = /auth/signout > authkit.form.authenticate.user.type = > authkit.users.sqlalchemy_04_driver:UsersFromDatabase > authkit.form.authenticate.user.data = authtest.model > ... > > # model/__init__.py > def setup_model(model, metadata, **p): > pass > > [EMAIL PROTECTED]:~/authtest$ paster serve --reload development.ini > Starting subprocess with file monitor > Traceback (most recent call last): > File "/home/pylons/bin/paster", line 8, in <module> > load_entry_point('PasteScript==1.3.6', 'console_scripts', 'paster') > () > File "/home/pylons/lib/python2.5/site-packages/PasteScript-1.3.6- > py2.5.egg/paste/script/command.py", line 78, in run > invoke(command, command_name, options, args[1:]) > File "/home/pylons/lib/python2.5/site-packages/PasteScript-1.3.6- > py2.5.egg/paste/script/command.py", line 117, in invoke > exit_code = runner.run(args) > File "/home/pylons/lib/python2.5/site-packages/PasteScript-1.3.6- > py2.5.egg/paste/script/command.py", line 212, in run > result = self.command() > File "/home/pylons/lib/python2.5/site-packages/PasteScript-1.3.6- > py2.5.egg/paste/script/serve.py", line 227, in command > relative_to=base, global_conf=vars) > File "/home/pylons/lib/python2.5/site-packages/PasteScript-1.3.6- > py2.5.egg/paste/script/serve.py", line 250, in loadapp > **kw) > File "/home/pylons/lib/python2.5/site-packages/PasteDeploy-1.3.1- > py2.5.egg/paste/deploy/loadwsgi.py", line 193, in loadapp > return loadobj(APP, uri, name=name, **kw) > File "/home/pylons/lib/python2.5/site-packages/PasteDeploy-1.3.1- > py2.5.egg/paste/deploy/loadwsgi.py", line 214, in loadobj > return context.create() > File "/home/pylons/lib/python2.5/site-packages/PasteDeploy-1.3.1- > py2.5.egg/paste/deploy/loadwsgi.py", line 606, in create > return self.object_type.invoke(self) > File "/home/pylons/lib/python2.5/site-packages/PasteDeploy-1.3.1- > py2.5.egg/paste/deploy/loadwsgi.py", line 99, in invoke > return fix_call(context.object, context.global_conf, > **context.local_conf) > File "/home/pylons/lib/python2.5/site-packages/PasteDeploy-1.3.1- > py2.5.egg/paste/deploy/util/fixtypeerror.py", line 57, in fix_call > val = callable(*args, **kw) > File "/home/pylons/authtest/authtest/config/middleware.py", line 54, > in make_app > app = authkit.authenticate.middleware(app, app_conf) > File "/home/pylons/lib/python2.5/site-packages/AuthKit-0.4.0- > py2.5.egg/authkit/authenticate/__init__.py", line 452, in middleware > prefix=prefix_, > File "/home/pylons/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 "/home/pylons/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 "/home/pylons/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 "/home/pylons/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' > > On Dec 20 2007, 1:11 pm, James Gardner <[EMAIL PROTECTED]> wrote: > > > Hi Enrico, > > > > Now the it seems that the 'sqlalchemy_04_driver' have some problem > > > with 'environ' object. > > > Ahh, you've been caught out by the different API used by the 0.4 driver. > > The first argument with the new API should be the WSGI environment. I > > can see why this doesn't quite work in the way you were expecting. If > > you do want to use this driver you'll need to setup the > > SQLAlchemyMiddleware first like this example does: > > >http://authkit.org/trac/browser/AuthKit/trunk/examples/user/database/... > > > Note this isn't the currently recommended way of using SQLAlchemy with > > Pylons, it is just the one I happen to like. > > > You might be better off with Lythoner's version perhaps if that works > > for you? > > > Cheers, > > > James --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
