Changeset - 988477a05db6
[Not reviewed]
default
0 3 0
Marcin Kuzminski - 16 years ago 2010-05-15 19:05:13
marcin@python-works.com
moved sqlalchemy session to base.
3 files changed with 1 insertions and 6 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/repos.py
Show inline comments
 
import logging
 
import os
 
from pylons import request, response, session, tmpl_context as c, url, app_globals as g
 
from pylons.controllers.util import abort, redirect
 
from pylons_app.lib import auth
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.model import meta
 
from pylons_app.model.db import Users, UserLogs
 
from pylons_app.lib.auth import authenticate
 
from pylons_app.model.hg_model import HgModel
 
from operator import itemgetter
 
import shutil
 
from pylons_app.lib.utils import invalidate_cache
 
@@ -18,16 +17,14 @@ class ReposController(BaseController):
 
    # To properly map this controller, ensure your config/routing.py
 
    # file has a resource setup:
 
    #     map.resource('repo', 'repos')
 
    
 
    @authenticate
 
    def __before__(self):
 
        
 
        c.admin_user = session.get('admin_user')
 
        c.admin_username = session.get('admin_username')
 
        self.sa = meta.Session
 
                
 
    def index(self, format='html'):
 
        """GET /repos: All items in the collection"""
 
        # url('repos')
 
        hg_model = HgModel()
 
        c.repos_list = list(hg_model.get_repos())
pylons_app/controllers/users.py
Show inline comments
 
@@ -2,13 +2,12 @@ import logging
 

	
 
from pylons import request, response, session, tmpl_context as c, url, app_globals as g
 
from pylons.controllers.util import abort, redirect
 

	
 
from pylons_app.lib.base import BaseController, render
 
from formencode import htmlfill
 
from pylons_app.model import meta
 
from pylons_app.model.db import Users, UserLogs
 
from pylons_app.lib.auth import authenticate
 
import crypt
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -17,16 +16,14 @@ class UsersController(BaseController):
 
    # To properly map this controller, ensure your config/routing.py
 
    # file has a resource setup:
 
    #     map.resource('user', 'users')
 
    
 
    @authenticate
 
    def __before__(self):
 
        
 
        c.admin_user = session.get('admin_user')
 
        c.admin_username = session.get('admin_username')
 
        self.sa = meta.Session
 
        
 
    def index(self, format='html'):
 
        """GET /users: All items in the collection"""
 
        # url('users')
 
        
 
        c.users_list = self.sa.query(Users).all()     
pylons_app/lib/base.py
Show inline comments
 
@@ -18,10 +18,11 @@ class BaseController(WSGIController):
 
    def __call__(self, environ, start_response):
 
        """Invoke the Controller"""
 
        # WSGIController.__call__ dispatches to the Controller method
 
        # the request is routed to. This routing information is
 
        # available in environ['pylons.routes_dict']
 
        c.repo_list = _get_repos()
 
        self.sa = meta.Session
 
        try:
 
            return WSGIController.__call__(self, environ, start_response)
 
        finally:
 
            meta.Session.remove()
0 comments (0 inline, 0 general)