11Custom Resources
22================
33
4- .. versionadded :: 0.5.0
5-
6- Sometimes there is a need to redefine a resource behaviour to achieve the needed goal. Python
7- Redmine provides a feature for such a case called custom resources. Basically this is just a
8- normal class inheritance made especially for Python Redmine.
4+ Sometimes there is a need to redefine a resource behaviour to achieve the needed goal.
5+ Python-Redmine provides a feature for such a case called custom resources. Basically this
6+ is just a normal class inheritance made especially for Python-Redmine.
97
108Configuration
119-------------
1210
13- To take advantage of this feature you need to tell Python Redmine where to search for your
14- custom resources. This should be done with a ``custom_resource_paths `` argument passed to
11+ To take advantage of this feature you need to tell Python- Redmine where to search for your
12+ custom resources. This should be done with a ``resource_paths `` argument passed to
1513the Redmine object which accepts a list or tuple of module paths which contain your custom
1614resources:
1715
1816.. code-block :: python
1917
20- redmine = Redmine(' https://redmine.url' , custom_resource_paths = (' foo.bar' , ' bar.baz' , ' foo.baz' ))
18+ redmine = Redmine(' https://redmine.url' , resource_paths = (' foo.bar' , ' bar.baz' , ' foo.baz' ))
2119
2220 .. note ::
2321
24- The ordering is very important. Python Redmine will search for the resources in this order:
22+ The ordering is very important. Python- Redmine will search for the resources in this order:
2523
26- #. foo.bar
27- #. bar.baz
28- #. foo.baz
29- #. redmine .resources
24+ #. foo.bar
25+ #. bar.baz
26+ #. foo.baz
27+ #. redminelib .resources
3028
3129Existing Resources
3230------------------
@@ -36,36 +34,36 @@ The list of existing resource class names that can be inherited from is availabl
3634Creation
3735--------
3836
39- To create a custom resource choose which resource behavior you want to change, e.g. Project :
37+ To create a custom resource choose which resource behavior you want to change, e.g. WikiPage :
4038
4139.. code-block :: python
4240
43- from redminelib.resources import Project
41+ from redminelib.resources import WikiPage
4442
45- class CustomProject ( Project ):
46- pass
43+ class CustomWikiPage ( WikiPage ):
44+ pass
4745
4846 Name
4947----
5048
51- Python Redmine converts underscore to camelcase when it tries to import the resource, that means
49+ Python- Redmine converts underscore to camelcase when it tries to import the resource, which means
5250that it is important to follow this convention to make everything work properly, e.g when you do:
5351
5452.. code-block :: python
5553
56- custom_wiki_page = redmine.custom_wiki_page.get(' Foo' )
54+ custom_wiki_page = redmine.custom_wiki_page.get(' Foo' )
5755
58- Python Redmine is searching for a resource class named CustomWikiPage in the modules defined via
59- the ``custom_resource_paths `` argument on Redmine object instantiation.
56+ Python- Redmine is searching for a resource class named CustomWikiPage in the modules defined via
57+ the ``resource_paths `` argument on Redmine object instantiation.
6058
6159Methods and Attributes
6260----------------------
6361
64- All existing resources are derived from a ``Resource `` class which you usually won't inherit from
65- directly unless you want to add support for a new resource which Python Redmine doesn't support.
62+ All existing resources are derived from a ``BaseResource `` class which you usually won't inherit from
63+ directly unless you want to add support for a new resource which Python- Redmine doesn't support.
6664Below you will find methods and attributes which can be redefined in your custom resource:
6765
68- .. autoclass :: redmine .resources.Resource
69- :members: __init__, __getattr__, __setattr__, refresh, pre_create, post_create, pre_update, post_update, save, encode, decode, bulk_encode, bulk_decode
70- :undoc-members:
71- :private-members:
66+ .. autoclass :: redminelib .resources.BaseResource
67+ :members: __getattr__, __setattr__, decode, encode, bulk_decode, bulk_encode, raw, refresh, pre_create, post_create, pre_update, post_update, pre_delete, post_delete, save, delete, export
68+ :undoc-members:
69+ :private-members:
0 commit comments