8000 Used plugin_pool.register_plugin() and apphook_pool.register() as dec… · django-cms/django-cms@9287f69 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9287f69

Browse files
sir-sigurdczpython
authored andcommitted
Used plugin_pool.register_plugin() and apphook_pool.register() as decorators in examples. (#6088)
* Used plugin_pool.register_plugin() as decorator in examples. plugin_pool.register_plugin() can be used as decorator since ac62acd. * Used apphook_pool.register() as decorator in examples. apphook_pool.register() can be used as decorator since 07e2b2e.
1 parent ae5a5b7 commit 9287f69

File tree

5 files changed

+8
-16
lines changed

5 files changed

+8
-16
lines changed

docs/how_to/apphooks.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ The file needs to contain a :class:`CMSApp <cms.app_base.CMSApp>` sub-class. For
3232
from cms.apphook_pool import apphook_pool
3333
from django.utils.translation import ugettext_lazy as _
3434

35+
@apphook_pool.register
3536
class MyApphook(CMSApp):
3637
name = _("My Apphook")
3738

3839
def get_urls(self, page=None, language=None, **kwargs):
3940
return ["myapp.urls"] # replace this with the path to your application's URLs module
4041

41-
apphook_pool.register(MyApphook)
42-
4342
.. versionchanged:: 3.3
4443
``CMSApp.get_urls()`` replaces ``CMSApp.urls``. ``urls`` is now deprecated and will be removed in
4544
version 3.5.

docs/how_to/custom_plugins.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,12 @@ In ``cms_plugins.py``, you place your plugins. For our example, include the foll
147147
from cms.models.pluginmodel import CMSPlugin
148148
from django.utils.translation import ugettext_lazy as _
149149

150+
@plugin_pool.register_plugin
150151
class HelloPlugin(CMSPluginBase):
151152
model = CMSPlugin
152153
render_template = "hello_plugin.html"
153154
cache = False
154155

155-
plugin_pool.register_plugin(HelloPlugin)
156-
157156
Now we're almost done. All that's left is to add the template. Add the
158157
following into the root template directory in a file called
159158
``hello_plugin.html``:
@@ -259,6 +258,7 @@ Now we need to change our plugin definition to use this model, so our new
259258

260259
from .models import Hello
261260

261+
@plugin_pool.register_plugin
262262
class HelloPlugin(CMSPluginBase):
263263
model = Hello
264264
name = _("Hello Plugin")
@@ -269,8 +269,6 @@ Now we need to change our plugin definition to use this model, so our new
269269
context = super(HelloPlugin, self).render(context, instance, placeholder)
270270
return context
271271

272-
plugin_pool.register_plugin(HelloPlugin)
273-
274272
We changed the ``model`` attribute to point to our newly created ``Hello``
275273
model and pass the model instance to the context.
276274

@@ -654,6 +652,7 @@ achieve this functionality:
654652
655653
from .models import ParentPlugin, ChildPlugin
656654
655+
@plugin_pool.register_plugin
657656
class ParentCMSPlugin(CMSPluginBase):
658657
render_template = 'parent.html'
659658
name = 'Parent'
@@ -667,9 +666,8 @@ achieve this functionality:
667666
context = super(ParentCMSPlugin, self).render(context, instance, placeholder)
668667
return context
669668
670-
plugin_pool.register_plugin(ParentCMSPlugin)
671-
672669
670+
@plugin_pool.register_plugin
673671
class ChildCMSPlugin(CMSPluginBase):
674672
render_template = 'child.html'
675673
name = 'Child'
@@ -683,8 +681,6 @@ achieve this functionality:
683681
context = super(ChildCMSPlugin, self).render(context, instance, placeholder)
684682
return context
685683
686-
plugin_pool.register_plugin(ChildCMSPlugin)
687-
688684
689685
``parent.html``:
690686

docs/how_to/namespaced_apphooks.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,13 @@ Now let's create the apphook, and set it up with support for multiple instances.
258258
from .cms_appconfig import FaqConfig
259259
260260
261+
@apphook_pool.register
261262
class FaqApp(CMSConfigApp):
262263
name = _("Faq App")
263264
urls = ["faq.urls"]
264265
app_name = "faq"
265266
app_config = FaqConfig
266267
267-
apphook_pool.register(FaqApp)
268-
269268
270269
Define a list view for FAQ entries
271270----------------------------------

docs/introduction/apphooks.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ This is a very basic example of an apphook for a django CMS application:
2828
from django.utils.translation import ugettext_lazy as _
2929
3030
31+
@apphook_pool.register # register the application
3132
class PollsApphook(CMSApp):
3233
app_name = "polls"
3334
name = _("Polls Application")
3435
3536
def get_urls(self, page=None, language=None, **kwargs):
3637
return ["polls.urls"]
3738
38-
apphook_pool.register(PollsApphook) # register the application
39-
4039
4140
Instead of defining the URL patterns in another file ``polls/urls.py``, it also is possible
4241
to return them directly, for instance as:

docs/introduction/plugins.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ For our poll plugin, we're going to write the following plugin class:
198198
from django.utils.translation import ugettext as _
199199
200200
201+
@plugin_pool.register_plugin # register the plugin
201202
class PollPluginPublisher(CMSPluginBase):
202203
model = PollPluginModel # model where plugin data are saved
203204
module = _("Polls")
@@ -208,8 +209,6 @@ For our poll plugin, we're going to write the following plugin class:
208209
context.update({'instance': instance})
209210
return context
210211
211-
plugin_pool.register_plugin(PollPluginPublisher) # register the plugin
212-
213212
.. note::
214213

215214
All plugin classes must inherit from :class:`cms.plugin_base.CMSPluginBase`

0 commit comments

Comments
 (0)
0