summaryrefslogtreecommitdiff
path: root/cherrypy
diff options
context:
space:
mode:
authorJared <flamableconcrete@gmail.com>2019-11-03 02:40:35 +0100
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2019-11-03 02:45:22 +0100
commitc9fe7debe89467ba74cbcd36a716fcc1ee191a53 (patch)
tree0202d4aae5da043c8dbd0e4d3392709fe0289f31 /cherrypy
parent8443f6b349a11f32ab446ad51a59ecd43ba61738 (diff)
downloadcherrypy-git-c9fe7debe89467ba74cbcd36a716fcc1ee191a53.tar.gz
Fix code blocks syntax in cherrypy._helper
Diffstat (limited to 'cherrypy')
-rw-r--r--cherrypy/_helper.py70
1 files changed, 39 insertions, 31 deletions
diff --git a/cherrypy/_helper.py b/cherrypy/_helper.py
index 328e4edb..d57cd1f9 100644
--- a/cherrypy/_helper.py
+++ b/cherrypy/_helper.py
@@ -83,53 +83,61 @@ def popargs(*args, **kwargs):
This decorator may be used in one of two ways:
As a class decorator:
- @cherrypy.popargs('year', 'month', 'day')
- class Blog:
- def index(self, year=None, month=None, day=None):
- #Process the parameters here; any url like
- #/, /2009, /2009/12, or /2009/12/31
- #will fill in the appropriate parameters.
- def create(self):
- #This link will still be available at /create. Defined functions
- #take precedence over arguments.
+ .. code-block:: python
+
+ @cherrypy.popargs('year', 'month', 'day')
+ class Blog:
+ def index(self, year=None, month=None, day=None):
+ #Process the parameters here; any url like
+ #/, /2009, /2009/12, or /2009/12/31
+ #will fill in the appropriate parameters.
+
+ def create(self):
+ #This link will still be available at /create.
+ #Defined functions take precedence over arguments.
Or as a member of a class:
- class Blog:
- _cp_dispatch = cherrypy.popargs('year', 'month', 'day')
- #...
+
+ .. code-block:: python
+
+ class Blog:
+ _cp_dispatch = cherrypy.popargs('year', 'month', 'day')
+ #...
The handler argument may be used to mix arguments with built in functions.
For instance, the following setup allows different activities at the
day, month, and year level:
- class DayHandler:
- def index(self, year, month, day):
- #Do something with this day; probably list entries
+ .. code-block:: python
- def delete(self, year, month, day):
- #Delete all entries for this day
+ class DayHandler:
+ def index(self, year, month, day):
+ #Do something with this day; probably list entries
- @cherrypy.popargs('day', handler=DayHandler())
- class MonthHandler:
- def index(self, year, month):
- #Do something with this month; probably list entries
+ def delete(self, year, month, day):
+ #Delete all entries for this day
- def delete(self, year, month):
- #Delete all entries for this month
+ @cherrypy.popargs('day', handler=DayHandler())
+ class MonthHandler:
+ def index(self, year, month):
+ #Do something with this month; probably list entries
- @cherrypy.popargs('month', handler=MonthHandler())
- class YearHandler:
- def index(self, year):
- #Do something with this year
+ def delete(self, year, month):
+ #Delete all entries for this month
- #...
+ @cherrypy.popargs('month', handler=MonthHandler())
+ class YearHandler:
+ def index(self, year):
+ #Do something with this year
- @cherrypy.popargs('year', handler=YearHandler())
- class Root:
- def index(self):
#...
+ @cherrypy.popargs('year', handler=YearHandler())
+ class Root:
+ def index(self):
+ #...
+
"""
# Since keyword arg comes after *args, we have to process it ourselves
# for lower versions of python.