comparison pylons_app/model/forms.py @ 367:a26f48ad7a8a

fixes issue #16 reimplementation of database repository, for using generic pk instead of repo naming as pk. Which caused to many problems. Fixed issue when redirecting after repo name change to 404. Removed update hook from basic app setup
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 27 Jul 2010 14:53:22 +0200
parents 98abf8953b87
children 55377fdc1fc6
comparison
equal deleted inserted replaced
366:0f35fa0f4eb8 367:a26f48ad7a8a
162 def to_python(self, value, state): 162 def to_python(self, value, state):
163 slug = h.repo_name_slug(value) 163 slug = h.repo_name_slug(value)
164 if slug in ['_admin']: 164 if slug in ['_admin']:
165 raise formencode.Invalid(_('This repository name is disallowed'), 165 raise formencode.Invalid(_('This repository name is disallowed'),
166 value, state) 166 value, state)
167
168 if old_data.get('repo_name') != value or not edit: 167 if old_data.get('repo_name') != value or not edit:
169 sa = meta.Session 168 sa = meta.Session
170 if sa.query(Repository).get(slug): 169 if sa.query(Repository).filter(Repository.repo_name == slug).scalar():
171 raise formencode.Invalid(_('This repository already exists') , 170 raise formencode.Invalid(_('This repository already exists') ,
172 value, state) 171 value, state)
173 meta.Session.remove() 172 meta.Session.remove()
174 return slug 173 return slug
175 174