12 messages in com.googlegroups.pylons-discussRe: AuthKit problems
FromSent OnAttachments
enrico secco17 Dec 2007 02:58 
Mike Orr17 Dec 2007 12:10 
Lythoner LY18 Dec 2007 18:39 
James Gardner19 Dec 2007 13:45 
enrico secco20 Dec 2007 02:27 
Lythoner LY20 Dec 2007 10:54.py
James Gardner20 Dec 2007 12:58 
James Gardner20 Dec 2007 13:11 
Adam Ryan25 Jan 2008 13:55 
n1ywb13 Feb 2008 13:33 
n1ywb14 Feb 2008 09:47 
n1ywb14 Feb 2008 10:53 
Subject:Re: AuthKit problems
From:Mike Orr (slug@public.gmane.org)
Date:12/17/2007 12:10:45 PM
List:com.googlegroups.pylons-discuss

Enrico, is this a new application written for Pylons 0.9.6.1? Or an older application you're updating? You're using some tools and tutorials that are way out of date.

On Dec 17, 2007 2:58 AM, enrico secco
<enri@public.gmane.org> wrote:

I'm trying to test the possibility to develop a web application in Pylons and I must handle the permission at row level of my db.

I did think to use AuthKit but I'm forced to use the UsersFromDatabase mode. I did try to test the funcionality on following the tutorial relative to QuickWiki in the Authentication and Authorization (PylonsBook)

Pylons' database support has changed since that chapter was written. James is working on a new draft. I haven't used AuthKit yet so I'll have to guess a bit here. The last comment in the Advanced AuthKit chapter says to use the newer driver in authkit.users.sqlalchemy_04_driver.UsersFromDatabase instead. So that's the first place to start. http://wiki.pylonshq.com/display/pysbook/Advanced+AuthKit

Next, we need to replace all occurances of 'ctx' and 'pylons.database' with something else, but it'll take a bit of time to unravel this.

but I don't be aple to pass the

paster setup-app development.ini

The first problem was the definition of 'meta' and 'ctx'. For meta I suppose that there was e change in QuickWiki because MetaData() is assigned to a 'metadata' variable. Then i add the line

meta = metadata

Yes, tutorial writers vacillate between using 'meta' or 'metadata' for that variable, but it's the same thing.

and for ctx insert 2 lines in QuickWiki model

from pylons.database import create_engine, session_context ... ctx = session_context()

No, no, no; that's two generations old. Structure your model according to "Making a Pylons Blog" http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog

"SQLAlchemy 0.4 for people in a hurry" explains the general database strategy for Pylons >= 0.9.6. It works as-is but will soon get two updates from the blog tutorial: the 'init_model' function (should use), and the 'pylons.g' dependency (should eliminate). http://wiki.pylonshq.com/display/pylonscookbook/SQLAlchemy+0.4+for+people+in+a+hurry

In either case you'll end up with a 'model.Session' object which is the successor to 'ctx'. So anywhere AuthKit uses 'ctx', use 'model.Session' instead.

I assume you have a single database containing both your data and permissions. If you're using multiple databases, it's slightly more complicated to set up.

root@ubuntuSVR:~# paster setup-app test.ini Running setup_config() from quickwiki.websetup /usr/lib/python2.5/site-packages/QuickWiki-0.1.5-py2.5.egg/quickwiki/ model/__init__.py:10: DeprecationWarning: pylons.database is deprecated, and will be removed from a future version of Pylons. SQLAlchemy 0.3.x users are recommended to migrate to SAContext (http:// cheeseshop.python.org/pypi/SAContext) for similar functionality

Ignore this.

from pylons.database import create_engine, session_context /usr/lib/python2.5/site-packages/Pylons-0.9.6.1-py2.5.egg/pylons/ database.py:142: SADeprecationWarning: SessionContext is deprecated. Use scoped_session().

Listen to this instead. it's what the above tutorials will give you.

If you see SAContext or 'sac' anywhere in the documentation, use its component parts from the model instead. sac.metadata => model.meta or model.metadata sac.session_context or sac.ctx => model.Session sac.engine["foo"] => model.engine (though you probably want model.Session.execute instead)

engine = create_engine(uri, echo=echo, **kwargs) File "/usr/lib/python2.5/site-packages/Pylons-0.9.6.1-py2.5.egg/ pylons/database.py", line 84, in create_engine assert uri AssertionError

The actual error is that sqlalchemy.create_engine was called with a blank URL (probably None though maybe ""). Rather than trace through why this happened, just restructure your code to avoid pylons.database.

""" The tables are created with all the constraints but not the istances 'delete' in the role ad admin in the user tables.

So somehow AuthKit is not able to use the SQLAlchemy engine/connection the other code is using.