--- 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)
--- 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):
--- 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):
+ """<input type='password'> without a confirmation field"""
+ type = 'password'
+
+
class FileInput(Input):
"""<input type='file'>"""
type = 'file'
--- 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)