X-Git-Url: http://git.veekun.com/zzz-spline-users.git/blobdiff_plain/546e4b9d5d72cfa36cca2f6f1d8f5cdc7225f329..a35a43eeaf6e7fe1247657ffffda8bb1735def12:/spline/plugins/users/__init__.py diff --git a/spline/plugins/users/__init__.py b/spline/plugins/users/__init__.py index 53633d7..e606823 100644 --- a/spline/plugins/users/__init__.py +++ b/spline/plugins/users/__init__.py @@ -1,17 +1,39 @@ +from pkg_resources import resource_filename + 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 controllers.accounts -import model as user_model +import spline.plugins.users.controllers.accounts +import spline.plugins.users.controllers.users +import spline.plugins.users.model + +def add_routes_hook(map, *args, **kwargs): + """Hook to inject some of our behavior into the routes configuration.""" + # Login, logout + map.connect('/accounts/login', controller='accounts', action='login') + map.connect('/accounts/login_begin', controller='accounts', action='login_begin') + map.connect('/accounts/login_finish', controller='accounts', action='login_finish') + map.connect('/accounts/logout', controller='accounts', action='logout') + + # Self-admin + map.connect('/users/{id};{name}/edit', controller='users', action='profile_edit') + + # Public user pages + map.connect('/users', controller='users', action='list') + map.connect('/users/{id};{name}', controller='users', action='profile') + map.connect('/users/{id}', controller='users', action='profile') def check_userid_hook(action, **params): """Hook to see if a user is logged in and, if so, stick a user object in c. """ + c.user = None + if not 'user_id' in session: return @@ -28,13 +50,28 @@ def check_userid_hook(action, **params): class UsersPlugin(PluginBase): def controllers(self): return dict( - accounts = controllers.accounts.AccountsController, + accounts = spline.plugins.users.controllers.accounts.AccountsController, + users = spline.plugins.users.controllers.users.UsersController, ) def model(self): - return [user_model.User, user_model.OpenID] + return [ + spline.plugins.users.model.User, + spline.plugins.users.model.OpenID, + ] + + def template_dirs(self): + return [ + (resource_filename(__name__, 'templates'), Priority.NORMAL) + ] def hooks(self): return [ - ('before_controller', 1, check_userid_hook), + ('routes_mapping', Priority.NORMAL, add_routes_hook), + ('before_controller', Priority.VERY_FIRST, check_userid_hook), + ] + + def widgets(self): + return [ + ('page_header', Priority.NORMAL, 'widgets/user_state.mako'), ]