from pkg_resources import resource_filename
-from pylons import c, session
+from pylons import c, config, session
-from spline.lib.plugin import PluginBase
from spline.lib.plugin import PluginBase, PluginLink, Priority
import spline.model.meta as meta
import splinext.users.controllers.accounts
+import splinext.users.controllers.admin
import splinext.users.controllers.users
from splinext.users import model as users_model
map.connect('/users/{id}', controller='users', action='profile',
conditions=dict(function=id_is_numeric))
+ # Big-boy admin
+ map.connect('/admin/users/permissions', controller='admin_users', action='permissions')
+
+def monkeypatch_user_hook(*args, **kwargs):
+ """Hook to tell the `User` model who the root user is."""
+ try:
+ users_model.User._root_user_id \
+ = int(config['spline-users.root_user_id'])
+ except KeyError:
+ # No config set; oh well!
+ pass
+
def check_userid_hook(action, **params):
"""Hook to see if a user is logged in and, if so, stick a user object in
c.
def controllers(self):
return dict(
accounts = splinext.users.controllers.accounts.AccountsController,
+ admin_users = splinext.users.controllers.admin.AdminController,
users = splinext.users.controllers.users.UsersController,
)
def hooks(self):
return [
('routes_mapping', Priority.NORMAL, add_routes_hook),
+ ('after_setup', Priority.NORMAL, monkeypatch_user_hook),
('before_controller', Priority.VERY_FIRST, check_userid_hook),
]