From: Eevee Date: Mon, 17 May 2010 02:27:56 +0000 (-0700) Subject: Use the local model module instead of spline.model. X-Git-Tag: veekun-promotions/2010060201~3 X-Git-Url: http://git.veekun.com/zzz-spline-users.git/commitdiff_plain/bad3786c6d51faaa6b206f0abdc6837dd9bedda7?ds=inline Use the local model module instead of spline.model. --- diff --git a/splinext/users/__init__.py b/splinext/users/__init__.py index 39318f0..73f2029 100644 --- a/splinext/users/__init__.py +++ b/splinext/users/__init__.py @@ -4,12 +4,11 @@ from pylons import c, session from spline.lib.plugin import PluginBase from spline.lib.plugin import PluginBase, PluginLink, Priority -import spline.model as model import spline.model.meta as meta import splinext.users.controllers.accounts import splinext.users.controllers.users -import splinext.users.model +from splinext.users import model as users_model def add_routes_hook(map, *args, **kwargs): """Hook to inject some of our behavior into the routes configuration.""" @@ -37,7 +36,7 @@ def check_userid_hook(action, **params): if not 'user_id' in session: return - user = meta.Session.query(model.User).get(session['user_id']) + user = meta.Session.query(users_model.User).get(session['user_id']) if not user: # Bogus id in the session somehow. Clear it del session['user_id'] @@ -54,12 +53,6 @@ class UsersPlugin(PluginBase): users = splinext.users.controllers.users.UsersController, ) - def model(self): - return [ - splinext.users.model.User, - splinext.users.model.OpenID, - ] - def template_dirs(self): return [ (resource_filename(__name__, 'templates'), Priority.NORMAL) diff --git a/splinext/users/controllers/accounts.py b/splinext/users/controllers/accounts.py index 9add733..a4c1b71 100644 --- a/splinext/users/controllers/accounts.py +++ b/splinext/users/controllers/accounts.py @@ -9,10 +9,10 @@ from pylons import config, request, response, session, tmpl_context as c, url from pylons.controllers.util import abort, redirect_to from routes import request_config -from spline import model from spline.model import meta from spline.lib import helpers as h from spline.lib.base import BaseController, render +from splinext.users import model as users_model log = logging.getLogger(__name__) @@ -74,8 +74,8 @@ class AccountsController(BaseController): try: # Grab an existing user record, if one exists - q = meta.Session.query(model.User) \ - .filter(model.User.openids.any(openid=res.identity_url)) + q = meta.Session.query(users_model.User) \ + .filter(users_model.User.openids.any(openid=res.identity_url)) user = q.one() except NoResultFound: # Try to pull a name out of the SReg response @@ -87,10 +87,10 @@ class AccountsController(BaseController): username = 'Anonymous' # Create db records - user = model.User(name=username) + user = users_model.User(name=username) meta.Session.add(user) - openid = model.OpenID(openid=res.identity_url) + openid = users_model.OpenID(openid=res.identity_url) user.openids.append(openid) meta.Session.commit() diff --git a/splinext/users/controllers/users.py b/splinext/users/controllers/users.py index 4afb9cd..dac037b 100644 --- a/splinext/users/controllers/users.py +++ b/splinext/users/controllers/users.py @@ -8,10 +8,10 @@ from pylons.controllers.util import abort, redirect_to from routes import request_config from sqlalchemy.orm.exc import NoResultFound -from spline import model from spline.model import meta from spline.lib import helpers as h from spline.lib.base import BaseController, render +from splinext.users import model as users_model log = logging.getLogger(__name__) @@ -42,7 +42,8 @@ class ProfileEditForm(Form): class UsersController(BaseController): def list(self): - c.users = meta.Session.query(model.User).order_by(model.User.id.asc()) + c.users = meta.Session.query(users_model.User) \ + .order_by(users_model.User.id.asc()) return render('/users/list.mako') def profile(self, id, name=None): @@ -52,7 +53,7 @@ class UsersController(BaseController): entirely optional and ignored. """ - c.page_user = meta.Session.query(model.User).get(id) + c.page_user = meta.Session.query(users_model.User).get(id) if not c.page_user: abort(404) @@ -60,7 +61,7 @@ class UsersController(BaseController): def profile_edit(self, id, name=None): """Main user profile editing.""" - c.page_user = meta.Session.query(model.User).get(id) + c.page_user = meta.Session.query(users_model.User).get(id) if not c.page_user: abort(404)