# HG changeset patch # User Sylvain Thénault # Date 1243323104 -7200 # Node ID bf27b4190739f449b0d77a7fab82dfb3a416035a # Parent f40ee76ecdf1dcbee631c245c2b028350789b2f6# Parent c5af2fbda5b63285b2518c39c7276817c0818db4 merge diff -r f40ee76ecdf1 -r bf27b4190739 etwist/server.py --- a/etwist/server.py Tue May 26 09:03:24 2009 +0200 +++ b/etwist/server.py Tue May 26 09:31:44 2009 +0200 @@ -196,7 +196,7 @@ if self.url_rewriter is not None: # XXX should occur before authentication? try: - path = self.url_rewriter.rewrite(host, origpath) + path = self.url_rewriter.rewrite(host, origpath, req) except Redirect, ex: return self.redirect(req, ex.location) request.uri.replace(origpath, path, 1) diff -r f40ee76ecdf1 -r bf27b4190739 web/form.py --- a/web/form.py Tue May 26 09:03:24 2009 +0200 +++ b/web/form.py Tue May 26 09:31:44 2009 +0200 @@ -261,13 +261,17 @@ self.restore_previous_post(self.session_key()) @iclassmethod - def field_by_name(cls_or_self, name, role='subject'): - """return field with the given name and role""" + def _fieldsattr(cls_or_self): if isinstance(cls_or_self, type): fields = cls_or_self._fields_ else: fields = cls_or_self.fields - for field in fields: + return fields + + @iclassmethod + def field_by_name(cls_or_self, name, role='subject'): + """return field with the given name and role""" + for field in cls_or_self._fieldsattr(): if field.name == name and field.role == role: return field raise FieldNotFound(name) @@ -275,20 +279,24 @@ @iclassmethod def remove_field(cls_or_self, field): """remove a field from form class or instance""" - if isinstance(cls_or_self, type): - fields = cls_or_self._fields_ - else: - fields = cls_or_self.fields - fields.remove(field) + cls_or_self._fieldsattr().remove(field) @iclassmethod def append_field(cls_or_self, field): """append a field to form class or instance""" - if isinstance(cls_or_self, type): - fields = cls_or_self._fields_ - else: - fields = cls_or_self.fields - fields.append(field) + cls_or_self._fieldsattr().append(field) + + @iclassmethod + def insert_field_before(cls_or_self, new_field, name, role='subject'): + field = cls_or_self.field_by_name(name, role) + fields = cls_or_self._fieldsattr() + fields.insert(fields.index(field), new_field) + + @iclassmethod + def insert_field_after(cls_or_self, new_field, name, role='subject'): + field = cls_or_self.field_by_name(name, role) + fields = cls_or_self._fieldsattr() + fields.insert(fields.index(field)+1, new_field) @property def form_needs_multipart(self): diff -r f40ee76ecdf1 -r bf27b4190739 web/formwidgets.py --- a/web/formwidgets.py Tue May 26 09:03:24 2009 +0200 +++ b/web/formwidgets.py Tue May 26 09:31:44 2009 +0200 @@ -109,6 +109,11 @@ return u'\n'.join(inputs) +class PasswordSingleInput(Input): + """ without a confirmation field""" + type = 'password' + + class FileInput(Input): """""" type = 'file' diff -r f40ee76ecdf1 -r bf27b4190739 web/views/apacherewrite.py --- a/web/views/apacherewrite.py Tue May 26 09:03:24 2009 +0200 +++ b/web/views/apacherewrite.py Tue May 26 09:31:44 2009 +0200 @@ -87,7 +87,8 @@ id = 'urlrewriter' rules = [] - def rewrite(self, host, path): + def rewrite(self, host, path, req): + self.req = req for cond in self.rules: if cond.match(host=host, path=path): return cond.process(path)