Skip to content

Commit

Permalink
corrected example documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeeland Chen authored and Yeeland Chen committed Apr 7, 2011
1 parent 3cb645c commit 6e19e81
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pyramid_routehelper/__init__.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ def add_resource(self, handler, member_name, collection_name, **kwargs):
Example:: Example::
>>> from pyramid.url import resource_url >>> from pyramid.url import route_path
>>> config.add_resource('myproject.handlers:LocationHandler', 'location', 'locations', >>> config.add_resource('myproject.handlers:LocationHandler', 'location', 'locations',
... parent_resource=dict(member_name='region', ... parent_resource=dict(member_name='region',
... collection_name='regions')) ... collection_name='regions'))
>>> # path_prefix is "regions/:region_id" >>> # path_prefix is "regions/:region_id"
>>> # name prefix is "region_" >>> # name prefix is "region_"
>>> resource_url('region_locations', region_id=13) >>> route_path('region_locations', region_id=13)
'/regions/13/locations' '/regions/13/locations'
>>> resource_url('region_new_location', region_id=13) >>> route_path('region_new_location', region_id=13)
'/regions/13/locations/new' '/regions/13/locations/new'
>>> resource_url('region_location', region_id=13, id=60) >>> route_path('region_location', region_id=13, id=60)
'/regions/13/locations/60' '/regions/13/locations/60'
>>> resource_url('region_edit_location', region_id=13, id=60) >>> route_path('region_edit_location', region_id=13, id=60)
'/regions/13/locations/60/edit' '/regions/13/locations/60/edit'
Overriding generated ``path_prefix``:: Overriding generated ``path_prefix``::
Expand All @@ -132,18 +132,17 @@ def add_resource(self, handler, member_name, collection_name, **kwargs):
... collection_name='regions'), ... collection_name='regions'),
... path_prefix='areas/:area_id') ... path_prefix='areas/:area_id')
>>> # name prefix is "region_" >>> # name prefix is "region_"
>>> url_for('region_locations', area_id=51) >>> route_path('region_locations', area_id=51)
'/areas/51/locations' '/areas/51/locations'
Overriding generated ``name_prefix``:: Overriding generated ``name_prefix``::
>>> m = Mapper() >>> config.add_resource('myproject.handlers:LocationHandler', 'location', 'locations',
>>> m.resource('location', 'locations',
... parent_resource=dict(member_name='region', ... parent_resource=dict(member_name='region',
... collection_name='regions'), ... collection_name='regions'),
... name_prefix='') ... name_prefix='')
>>> # path_prefix is "regions/:region_id" >>> # path_prefix is "regions/:region_id"
>>> url_for('locations', region_id=51) >>> route_path('locations', region_id=51)
'/regions/51/locations' '/regions/51/locations'
""" """


Expand Down

0 comments on commit 6e19e81

Please sign in to comment.