Skip to content

Commit

Permalink
Add kotti.base_includes, making kotti.includes empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnouri committed Mar 3, 2011
1 parent 987fde2 commit de6462a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
39 changes: 14 additions & 25 deletions README.rst
Expand Up @@ -154,18 +154,17 @@ templates. The defaults are::
kotti.templates.view_css = kotti:static/view.css
kotti.templates.edit_css = kotti:static/edit.css

*kotti.includes*
----------------
*kotti.includes* and *kotti.base_includes*
------------------------------------------

The default configuration here is::
``kotti.includes`` allows for convenient extension of Kotti with
additional views, content types and event handlers. An example::

kotti.includes =
kotti.events kotti.views.view kotti.views.edit
kotti.views.login kotti.views.site_setup
kotti.includes = mypackage.views mypackage.events

These point to modules that contain an ``includeme`` function. An
``includeme`` function that registers an edit view for an ``Event``
resource might look like this::
You should list here modules that contain an ``includeme`` function.
A ``mypackage.views`` module could have this function, which will
register an edit view for a hypothetical event content type::

def includeme(config):
config.add_view(
Expand All @@ -175,22 +174,12 @@ resource might look like this::
permission='edit',
)

Examples of views and their registrations are in Kotti itself. Take a
look at ``kotti.views.view`` and ``kotti.views.edit``. XXX Need
example extension package.

Changing the ``kotti.includes`` configuration allows you to register
your own views or event handlers in addition to, or instead of Kotti's
defaults. To include hypothetical views from package A and event
handlers, you woudl write something like this::
``kotti.base_includes`` is a list of modules that Kotti itself defines
for inclusion. The default::

kotti.includes =
kotti.events kotti.views.view kotti.views.edit
kotti.views.login kotti.views.site_setup
A.views B.events

XXX We need another variable that's just for adding, like
``kotti.includes_add``.

Note that it's also possible to set these options directly from your
Python package by use of the `kotti.configurators`_ configuration
Expand All @@ -199,7 +188,8 @@ variable.
*kotti.available_types*
-----------------------

The default configuration here is::
Defines the list of content types available. The default
configuration here is::

kotti.available_types = kotti.resources.Document

Expand Down Expand Up @@ -244,11 +234,10 @@ function that configures Kotti::

# in mypackage/__init__.py
def kotti_configure(config):
config['kotti.includes'] += ' mypackage.views'
config['kotti.base_includes'] += ' mypackage.views'
config['kotti.principals'] = 'mypackage.security.principals'
config['kotti.authn_policy_factory'] = 'mypackage.security.authn_factory'

And this is how you'd hook it up in the ``pasteserve.ini``::
And this is how you'd hook it up in the Paste Serve ini file::
kotti.configurators = mypackage.kotti_configure

Expand Down
9 changes: 6 additions & 3 deletions kotti/__init__.py
Expand Up @@ -51,7 +51,8 @@ def none_factory(**kwargs): # pragma: no cover
'kotti.templates.view_css': 'kotti:static/view.css',
'kotti.templates.edit_css': 'kotti:static/edit.css',
'kotti.configurators': '',
'kotti.includes': 'kotti.events kotti.views.view kotti.views.edit kotti.views.login kotti.views.site_setup',
'kotti.base_includes': 'kotti.events kotti.views.view kotti.views.edit kotti.views.login kotti.views.site_setup',
'kotti.includes': '',
'kotti.available_types': 'kotti.resources.Document',
'kotti.authn_policy_factory': 'kotti.authtkt_factory',
'kotti.authz_policy_factory': 'kotti.acl_factory',
Expand All @@ -60,6 +61,7 @@ def none_factory(**kwargs): # pragma: no cover
},
dotted_names=set([
'kotti.configurators',
'kotti.base_includes',
'kotti.includes',
'kotti.available_types',
'kotti.authn_policy_factory',
Expand Down Expand Up @@ -105,8 +107,9 @@ def main(global_config, **settings):

_configure_base_views(config)

# Include modules listed in 'includeme' configuration:
for module in configuration['kotti.includes']:
# Include modules listed in 'kotti.includes' and 'kotti.includes':
for module in (
configuration['kotti.base_includes'] + configuration['kotti.includes']):
config.include(module)

return config.make_wsgi_app()
Expand Down
4 changes: 2 additions & 2 deletions kotti/tests.py
Expand Up @@ -77,14 +77,14 @@ class MyType(object):
pass

def my_configurator(conf):
conf['kotti.includes'] = ''
conf['kotti.base_includes'] = ''
conf['kotti.available_types'] = [MyType]

settings = self.required_settings()
settings['kotti.configurators'] = [my_configurator]
main({}, **settings)

self.assertEqual(kotti.configuration['kotti.includes'], [])
self.assertEqual(kotti.configuration['kotti.base_includes'], [])
self.assertEqual(kotti.configuration['kotti.available_types'], [MyType])

class TestNode(UnitTestBase):
Expand Down

0 comments on commit de6462a

Please sign in to comment.