import spline.model.meta as meta
import spline.plugins.users.controllers.accounts
+import spline.plugins.users.controllers.users
import spline.plugins.users.model
def add_routes_hook(map, *args, **kwargs):
map.connect('/accounts/login_finish', controller='accounts', action='login_finish')
map.connect('/accounts/logout', controller='accounts', action='logout')
+ map.connect('/users/{id};{name}', controller='users', action='view')
+ map.connect('/users/{id}', controller='users', action='view')
+
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 = spline.plugins.users.controllers.accounts.AccountsController,
+ users = spline.plugins.users.controllers.users.UsersController,
)
def model(self):
--- /dev/null
+import logging
+
+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 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
+
+log = logging.getLogger(__name__)
+
+class UsersController(BaseController):
+
+ def index(self):
+ # Return a rendered template
+ # return render('/template.mako')
+ # or, Return a response
+ return 'stub'
+
+ def view(self, id, name=None):
+ """User page.
+
+ URL is /users/id:name, where 'name' only exists for readability and is
+ entirely optional and ignored.
+ """
+
+ c.page_user = meta.Session.query(model.User).get(id)
+ if not c.page_user:
+ abort(404)
+
+ return render('/users/view.mako')
--- /dev/null
+<%inherit file="/base.mako" />
+<%def name="title()">${c.page_user.name} - Users</%def>
+<%def name="title_in_page()">User: ${c.page_user.name}</%def>
+
+<h1>${c.page_user.name}</h1>
+
+A user!