Mercurial > public > src > rhodecode
comparison pylons_app/lib/auth.py @ 374:664a5b8c551a
Added application settings, are now customizable from database
fixed all instances of sqlachemy to be removed() after execution.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 14 Jul 2010 18:31:06 +0200 |
parents | 6484963056cd |
children | 5bbcc0cac389 |
comparison
equal
deleted
inserted
replaced
373:031152a540c5 | 374:664a5b8c551a |
---|---|
45 | 45 |
46 | 46 |
47 @cache_region('super_short_term', 'cached_user') | 47 @cache_region('super_short_term', 'cached_user') |
48 def get_user_cached(username): | 48 def get_user_cached(username): |
49 sa = meta.Session | 49 sa = meta.Session |
50 user = sa.query(User).filter(User.username == username).one() | 50 try: |
51 user = sa.query(User).filter(User.username == username).one() | |
52 finally: | |
53 meta.Session.remove() | |
51 return user | 54 return user |
52 | 55 |
53 def authfunc(environ, username, password): | 56 def authfunc(environ, username, password): |
54 password_crypt = get_crypt_password(password) | 57 password_crypt = get_crypt_password(password) |
55 try: | 58 try: |
87 permissions since adding a new permission also requires application restart | 90 permissions since adding a new permission also requires application restart |
88 ie. to decorate new views with the newly created permission | 91 ie. to decorate new views with the newly created permission |
89 @param config: | 92 @param config: |
90 """ | 93 """ |
91 log.info('getting information about all available permissions') | 94 log.info('getting information about all available permissions') |
92 sa = meta.Session | 95 try: |
93 all_perms = sa.query(Permission).all() | 96 sa = meta.Session |
97 all_perms = sa.query(Permission).all() | |
98 finally: | |
99 meta.Session.remove() | |
100 | |
94 config['available_permissions'] = [x.permission_name for x in all_perms] | 101 config['available_permissions'] = [x.permission_name for x in all_perms] |
95 | 102 |
96 def set_base_path(config): | 103 def set_base_path(config): |
97 config['base_path'] = config['pylons.app_globals'].base_path | 104 config['base_path'] = config['pylons.app_globals'].base_path |
98 | 105 |
138 #set write if owner | 145 #set write if owner |
139 if perm.Repository.user_id == user.user_id: | 146 if perm.Repository.user_id == user.user_id: |
140 p = 'repository.write' | 147 p = 'repository.write' |
141 else: | 148 else: |
142 p = perm.Permission.permission_name | 149 p = perm.Permission.permission_name |
143 user.permissions['repositories'][perm.Repo2Perm.repository] = p | 150 user.permissions['repositories'][perm.Repo2Perm.repository] = p |
151 meta.Session.remove() | |
144 return user | 152 return user |
145 | 153 |
146 def get_user(session): | 154 def get_user(session): |
147 """ | 155 """ |
148 Gets user from session, and wraps permissions into user | 156 Gets user from session, and wraps permissions into user |