<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,14 +4,15 @@ from controller import Expose, Filter
 from session import SessionStore
 from utils import recursive_merge, get_default_favicon, defaults
 # Import Route for ease of use.
-from router import Route
+from router import Route, Controller_Route
 
 class Constrictor(object):
   # Importing version number and representation function.
   import __init__ as version
   # Sub-classing:
   from controller import Controller
-  from router import Route # Also imported here for convenience, I guess.
+  from router import Route, Controller_Route
+  # ^ Also imported here for convenience, I guess.
   # - Request class used in routing and processing system.
   from request import Request
   </diff>
      <filename>core.py</filename>
    </modified>
    <modified>
      <diff>@@ -24,4 +24,24 @@ class Route(object):
     else:
       # The URL matched, grab the params tuple.
       params = match.groups()
-      return (self.func, params)
\ No newline at end of file
+      return (self.func, params)
+class Controller_Route(object):
+  &quot;&quot;&quot;
+  Takes a controller and allows for easy auto-routing to it's methods in the
+  style &quot;/controller/method/params&quot;.
+  &quot;&quot;&quot;
+  def __init__(self, controller, controller_name = False):
+    self.controller = controller
+    if not controller_name: controller_name = controller.__name__.lower()
+    self.route_rec = re.compile(r'^/%s/?([0-9A-z-_]+)?/?([^/]+)?/?$' % controller_name)
+  def match(self, url):
+    match = self.route_rec.match(url)
+    if not match is None:
+      groups = match.groups()
+      method_name = groups[0];params = groups[1]
+      if method_name is None: method_name = 'index'
+      try:
+        method = type.__getattribute__(self.controller, method_name)
+        return (method, params)
+      except AttributeError: return None
+    else: return None
\ No newline at end of file</diff>
      <filename>router.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>414c4f4acf778b5a2dc2940a09f16e61f2bae461</id>
    </parent>
  </parents>
  <author>
    <name>Dirk Gadsden</name>
    <email>dirk@esherido.com</email>
  </author>
  <url>http://github.com/dirk/constrictor/commit/d5aa8cbcfe51f1733bb979a247f7a44e2ab461e8</url>
  <id>d5aa8cbcfe51f1733bb979a247f7a44e2ab461e8</id>
  <committed-date>2009-06-05T14:25:34-07:00</committed-date>
  <authored-date>2009-06-05T14:25:34-07:00</authored-date>
  <message>Added Rails-style controller/method auto-router</message>
  <tree>f96b1f9fb0b6344dcf1c7b016b6206d046f4a9fe</tree>
  <committer>
    <name>Dirk Gadsden</name>
    <email>dirk@esherido.com</email>
  </committer>
</commit>
