Identity Sample

Enough folks have had trouble getting the TurboGears identity framework to work that I thought I’d share the project I’ve been using to test various features as I add them.

The one user is jeff with password foobar.

There are two interesting pages: /secured and /logout. In order to see the secured page, you’ll have to authenticate. When you request the /logout page, you’re identity session is terminated.

This sample also demonstrates using the current identity from within a template.

Note: This sample will not work with the latest TurboGears code. Changes were made to the predicates and other code that makes this sample invalid. I’ll see if I can’t update the sample soon. (1/2/2006)

9 Comments

  1. Posted 13 Nov 2005 at 9:29 am | Permalink

    Thanks jeff I was a bit lost in the identity code as a newbie to python :(, it works now !!! I must have messed up with soProvider , provider and the “identity.current” wrapper, sorry to bother you and thanks again for the sample. Benoit

  2. Posted 13 Nov 2005 at 9:31 am | Permalink

    Benoit, don’t mention it. I’m a newbie to Python too: I only started looking at it when I downloaded TurboGears the first time. Given that there is no documentation for the identity framework yet, I expect it to be a little difficult to pick up. I’m really doing my best to remedy that deficiency, but there are other pressing interests… like building a real ORM for Python…

  3. michele
    Posted 14 Nov 2005 at 4:55 pm | Permalink

    Jeff you might want to join planet.turbogears.org, I noticed this post from a technorati search.

    Send an email to tgplanet@splee.co.uk

    Great work!

    Just wondering, what do you intend with “a real ORM for Pyton…”, isn’t SQLObject the right thing?

  4. Posted 14 Nov 2005 at 6:32 pm | Permalink

    Yeah, I’ve spoken to Lee and I’d like to subscribe only the TurboGears category. At the moment, I don’t have Movable Type configured to provide a feed for each category.

    On the subject of ORM, I’m looking to create something a little more Hibernate-like that aggressively caches and attempts to minimise the number of server requests. I’ve already got quite a lot of working code (it really isn’t that hard because I’ve written ORMs before).

    For a quick glance, point your browser (or subversion client) at http://newburyportion.com/svn/orm/

  5. Martin
    Posted 28 Nov 2005 at 3:01 pm | Permalink

    Where do I download the file identity-sample.tgz ? I don’t see a link. Or am I being stupid ?

    Martin

  6. Posted 28 Nov 2005 at 3:16 pm | Permalink

    Martin, you’re not being stupid. When I changed Web site software I broke this feature. Sorry. I’ll have to fix it soon.

    Until I can fix it, you can download the file from:

    http://nerd.newburyportion.com/downloads/identity-sample.tgz

  7. Martin
    Posted 28 Nov 2005 at 4:39 pm | Permalink

    Thanks for the link. Got the code now, but it fails with a “OperationalError: no such table: tg_user”.

    I am on Windows, Python 2.4.

    Martin

  8. Posted 28 Nov 2005 at 4:52 pm | Permalink

    Ah! That would be because you have a more recent version of the TurboGears code than this sample was built for.

    You’ll need to delete the database and recreate it using:

    tg-admin sql create
    

    Then create a new user and group with:

    tg-admin shell
    >>> # Create the User & Group instances
    

    I’m not at a machine that has TurboGears installed or I’d test this. But it should be rather self explanatory.

  9. Martin
    Posted 28 Nov 2005 at 5:34 pm | Permalink

    Thanks, got it working now. You might want to note somewhere the obvious fact that the dev.cfg db url has to be edited. There is a small typo in step 10 in the http://trac.turbogears.org/turbogears/wiki/IdentityManagement page – somodel is missing from the import statement. I would edit it myself, but the Trac server fail when I try.

    Martin