Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1238 (closed defect: fixed)

Opened 12 years ago

Last modified 11 years ago

[PATCH] Allow TurboGears to save visit to a separate db

Reported by: abadger1999 Owned by: tbradshaw
Priority: normal Milestone: 1.0.4
Component: TurboGears Version: 1.0
Severity: normal Keywords:
Cc:

Description

In my environment we're deploying several TurboGears applications that use a common authentication framework. We'd like to use the same visit tables for each application so the end-user can log in once and then access any of the applications. The way that we're doing this is to pull the visit table out of the individual application database and put it in a sitewide database where each application can access it.

When doing this, I discovered a few areas of visit/savisit.py and identity/saprovider.py that assumed that the visit framework exists in the application's database and tried to use turbogears.session to access the visit table. Since subclassing these classes and only overriding the necessary methods is the easiest way to create a new provider, these accesses prevent people from creating the visit structure in a secondary table in the most logical manner.

I modified the calls in savisit.py and saprovider.py to pull the session from the class's mapper instead of using turbogeears.session. This works with the example Visit model created by tg-admin quickstart since it uses assignmapper. I'm new enough to TurboGears and sqlalchemy that I don't know if it's proper to depend on assignmapper being used here or if another method needs to be decided upon.

Attachments

turbogears-sa-seconddb.diff Download (2.7 KB) - added by abadger1999 12 years ago.
Patch to allow visit tables to exist in a different database

Change History

Changed 12 years ago by abadger1999

Patch to allow visit tables to exist in a different database

comment:1 Changed 12 years ago by abadger1999

Note -- this patch was created against the trunk but it also applies to 1.0. I'm currently using 1.0b2 and would love to se it go into the 1.0 branch.

comment:2 Changed 12 years ago by alberto

Could we have a test-case for this? I'm not an identity user so I cannot check myself if this patch works as expected or does not cause any unintended consequences.

Thanks :) Alberto

comment:3 follow-up: ↓ 4 Changed 12 years ago by abadger1999

Hmm.. There's no existing tests for identity/saprovider or visit for me to examine :-(

nosetest looks like it's just a variant of unittest so I can probably write a test case that checks for the problem this patch fixes. Because of my newness to identity (and turbogears in general), though, I can't write a test case that checks for unintended consequences as I'm not sure what those would be.

Who's the sqlalchemy identity and visit author?

comment:4 in reply to: ↑ 3 Changed 12 years ago by alberto

Replying to abadger1999:

Hmm.. There's no existing tests for identity/saprovider or visit for me to examine :-(

nosetest looks like it's just a variant of unittest so I can probably write a test case that checks for the problem this patch fixes.

That's good enough and much appreciated. nosetests will run any unittest.TestCase? it finds so a TestCase? is all you need, take a look at http://trac.turbogears.org/browser/branches/1.0/turbogears/identity/tests/test_identity.py for the current identity tests for inspiration.

Because of my newness to identity (and turbogears in general), though, I can't write a test case that checks for unintended consequences as I'm not sure what those would be.

As long as current tests all pass (ignore ones relating html case if using kid 0.9.4 or apply http://trac.turbogears.org/attachment/ticket/1234/testing_for_all_kid_versions.patch) you'll be fione raegarding "unintended consequences"

Who's the sqlalchemy identity and visit author?

Jeff Watkins plus many other contributors.

Thanks for the patches :)

Alberto

comment:5 Changed 12 years ago by abadger1999

I give up. I can't write a test for this because there's no sqlalchemy identity tests at the moment. Trying to write the setup portion just bombs out in sqlalchemy code. Someone else really needs to write the tests for sqlalchemy identity before I can write a test case that adds this problem onto it.

comment:6 Changed 12 years ago by alberto

Can anyone using sqlalchemy identity please try this patch and report back to see if it, at least, doesn't break anything?

(Whoever writes up some tests for sa identity will become my personal hero for the season ;)

Thanks,

Alberto

comment:7 Changed 12 years ago by alberto

  • Milestone changed from 1.0.1 to 1.0.2

comment:8 Changed 11 years ago by tbradshaw

  • Owner changed from anonymous to tbradshaw
  • Status changed from new to assigned

I use sa identity. I'll write some test cases.

comment:9 Changed 11 years ago by alberto

  • Milestone changed from 1.0.2 to 1.0.3

comment:10 Changed 11 years ago by faide

  • Summary changed from Allow TurboGears to save visit to a separate db to [PATCH] Allow TurboGears to save visit to a separate db

comment:11 Changed 11 years ago by Chris Arndt

  • Milestone changed from 1.0.3 to 1.0.4

Batch promoting 1.0.3 tickets to Milestone 1.0.4

comment:12 Changed 11 years ago by paj

  • Status changed from assigned to closed
  • Resolution set to fixed

This should have been fixed by a recent change that makes database.session not bound to a particular database.

Creating SA identity unit tests is in #1453

Going to close this for now.

Note: See TracTickets for help on using tickets.