diff options
| author | ianb <devnull@localhost> | 2005-07-21 20:02:06 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-07-21 20:02:06 +0000 |
| commit | 7d4f6ea9abc4753ba54378079f9bb0e717e244ee (patch) | |
| tree | e32d13a6de272cdf96954fd02ef70f8df2f79825 | |
| parent | f4c73e32a9434332af8e2343b4c611932b6929f5 (diff) | |
| download | paste-7d4f6ea9abc4753ba54378079f9bb0e717e244ee.tar.gz | |
Added docstrings
| -rw-r--r-- | paste/wareweb/dispatch.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/paste/wareweb/dispatch.py b/paste/wareweb/dispatch.py index 9b8b5c4..486921c 100644 --- a/paste/wareweb/dispatch.py +++ b/paste/wareweb/dispatch.py @@ -9,6 +9,18 @@ def public(func): class MethodDispatch(object): + """ + This is an *abstract* class. It implements generic dispatching + to servlet methods. See ``ActionDispatch`` and ``PathDispatch`` + for implementations. + + Methods are considered public if their ``public`` attribute is + true (you can use the ``@public`` decorator to set this) or if the + method name is prefixed appropriately. (E.g., if ``prefix`` is + ``action_`` then ``action_meth()`` will be considered the public + method by the name ``meth`` -- the prefix is added automatically!) + """ + prefix = None def __addtoclass__(self, attr, cls): @@ -45,6 +57,21 @@ class MethodDispatch(object): class ActionDispatch(MethodDispatch): + """ + This dispatches to a method based on a URL variable (GET or POST + -- remember that you can also include GET variables in your form's + ``action`` even if the form is being POSTed). + + The URL variable indicates a method to run; if no variable is + found then ``default_action`` is assumed (if you pass in a default + action). + + The URL variable is given with ``action_name`` and defaults to + ``'_action_'``. You can pass in the action either as + ``_action_=method_name`` or ``_action_method_name=anything`` + (useful with submit buttons, where the value is part of the UI). + """ + prefix = 'action_' def __init__(self, action_name='_action_', default_action=None): @@ -79,6 +106,14 @@ class ActionDispatch(MethodDispatch): class PathDispatch(MethodDispatch): + """ + This dispatches to a method based on the ``PATH_INFO``. Thus + ``/path/to/servlet/meth`` will call the ``meth`` method. + + @@: This should probably adjust SCRIPT_NAME and PATH_INFO + @@: Should these all use the same prefix? + """ + prefix = 'path_' def find_method(self, servlet, ret_value, **kw): |
