1. dlutcat
  2. WebHelpers


slug...@gmail.com  committed 2001fc5 Merge


  • Participants
  • Parent commits 069d2d1, 27641bb
  • Branches trunk

Comments (0)

Files changed (4)


View file
  • Ignore whitespace
 tip (development version)
+* Delete ``webhelpers.string24``.  WebHelpers no longer supports Python 2.3.
 * webhelpers.html.grid_demo:
   - Demonstrates ``webhelpers.html.grid``. Run as 
   - Moved to its own module.
   - Changed ``Flash.__html__()`` implementation.
+  - Categories may be specified in constructor. Patch by Eli Collins.
 * webhelpers.pylonslib.grid:
   - Bugfixes.
-* webhelpers.string24:
+* webhelpers.util:
-  - Delete module. WebHelpers no longer supports Python 2.3.
+  - Bugfix: ``parse_qs`` moved from ``cgi`` to ``urlparse`` in Python 2.6.
+    Patch by Mike Verdone.
 1.0b3 (2009-12-29)

File unfinished/document.py

View file
  • Ignore whitespace
     def html4(self):
         doctype = self.doctype or Doctype().html4()
+    # XXX Allow subclassing for custom heads. Refactor into superclass with
+    # get_head method?
     #### Private methods
     def _get_dict(self, dic):
         if dic is None:

File webhelpers/pylonslib/flash.py

View file
  • Ignore whitespace
 messages below a certain level; it returns all messages set. 
 You can change the standard categories by overriding the ``.categories``
-and ``.default_category`` class attributes.
+and ``.default_category`` class attributes, or by providing alternate
+values using constructor keywords.
 Note that messages are _not_ grouped by category, nor is it possible to 
 pop one category of messages while leaving the others.  If you want to 
     # Default category if none is specified.
     default_category = "notice"
-    def __init__(self, session_key="flash"):
+    def __init__(self, session_key="flash", categories=None, default_category=None):
         """Instantiate a ``Flash`` object.
         ``session_key`` is the key to save the messages under in the user's
-        session.
+        session. 
+        ``categories`` is an optional list which overrides the default list 
+        of categories. 
+        ``default_category`` overrides the default category used for messages 
+        when none is specified.
         self.session_key = session_key
+        if categories is not None:
+            self.categories = categories
+        if default_category is not None:
+            self.default_category = default_category
+        if self.categories and self.default_category not in self.categories:
+            raise ValueError("unrecognized default category %r" % (self.default_category,))
     def __call__(self, message, category=None):
         """Add a message to the session.
         if not category:
             category = self.default_category
         elif self.categories and category not in self.categories:
-            raise ValueError("unrecognized category '%s'" % category)
+            raise ValueError("unrecognized category %r" % (category,))
         # Don't store Message objects in the session, to avoid unpickling
         # errors in edge cases.
         from pylons import session

File webhelpers/util.py

View file
  • Ignore whitespace
 from UserDict import DictMixin
 from xml.sax.saxutils import XMLGenerator
+    from urlparse import parse_qs
+except ImportError:   # Python < 2.6
+    from cgi import parse_qs
 def update_params(url, **params):
     """Update query parameters in a URL.
     url, fragment = urlparse.urldefrag(url)
     if "?" in url:
         url, qs = url.split("?", 1)
-        query = urlparse.parse_qs(qs)
+        query = parse_qs(qs)
         query = {}
     for key, value in params.iteritems():