Skip to content

Commit

Permalink
Add missing docstrings, convert instance to static methods where poss…
Browse files Browse the repository at this point in the history
…ible.
  • Loading branch information
disko committed Jan 4, 2016
1 parent b9eea89 commit 42c36e0
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 3 deletions.
6 changes: 6 additions & 0 deletions kotti/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ def base_configure(global_config, **settings):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

import kotti.views.util

settings = config.get_settings()
Expand Down
3 changes: 2 additions & 1 deletion kotti/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def _make_config(location):
cfg.set_main_option("sqlalchemy.url", get_settings()['sqlalchemy.url'])
return cfg

def _make_script_dir(self, alembic_cfg):
@staticmethod
def _make_script_dir(alembic_cfg):
script_dir = ScriptDirectory.from_config(alembic_cfg)
script_dir.__class__ = ScriptDirectoryWithDefaultEnvPy # O_o
return script_dir
Expand Down
5 changes: 5 additions & 0 deletions kotti/sanitizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def handler(event):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

_setup_sanitizers(config.registry.settings)
_setup_listeners(config.registry.settings)
19 changes: 19 additions & 0 deletions kotti/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,27 @@ def asset(name):


def includeme_login(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.add_view(
login_view,
name='login',
renderer='kotti:templates/login.pt')


def includeme_layout(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

# override edit master layout with view master layout

config.override_asset(
to_override='kotti:templates/edit/master.pt',
override_with='kotti:templates/view/master.pt')
Expand Down Expand Up @@ -262,6 +275,12 @@ def dummy_view(context, request):


def include_testing_view(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.add_view(
dummy_view,
context=TestingRootFactory,
Expand Down
11 changes: 9 additions & 2 deletions kotti/traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __call__(self, request):
else:
vpath_tuple = split_path_info(vpath)
traversed_nodes = self.traverse(root, vpath_tuple)
if len(traversed_nodes) == 0:
if not traversed_nodes:
view_name = vpath_tuple[0]
if view_name[:lvs] == vs:
view_name = view_name[lvs:]
Expand Down Expand Up @@ -179,7 +179,8 @@ def traverse(root, vpath_tuple):

return nodes

def _traverse_cte(self, root, vpath_tuple): # pragma: no cover
@staticmethod
def _traverse_cte(root, vpath_tuple): # pragma: no cover
""" Version of the traverse method, that uses a CTE instead of the
Node.path attribute. Unfortunately this is **much** slower and works
only on PostgreSQL.
Expand Down Expand Up @@ -233,4 +234,10 @@ def _traverse_cte(self, root, vpath_tuple): # pragma: no cover


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.add_traverser(NodeTreeTraverser, Node)
6 changes: 6 additions & 0 deletions kotti/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def __init__(self, context, request):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.add_static_view('static-kotti', 'kotti:static')

# deform stuff
Expand Down
6 changes: 6 additions & 0 deletions kotti/views/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,10 @@ def set_cache_headers(event):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)
6 changes: 6 additions & 0 deletions kotti/views/edit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ def _states(context, request):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

pass
6 changes: 6 additions & 0 deletions kotti/views/edit/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ def actions(context, request):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Expand Down
6 changes: 6 additions & 0 deletions kotti/views/edit/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ def add(self, **appstruct):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.add_view(
DocumentEditForm,
context=Document,
Expand Down
6 changes: 6 additions & 0 deletions kotti/views/edit/default_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,10 @@ def set_default_view(self):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan('.default_views')
6 changes: 6 additions & 0 deletions kotti/views/edit/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,10 @@ def process_upload(self):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)
6 changes: 6 additions & 0 deletions kotti/views/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def attachment_view(context, request):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)


Expand Down
6 changes: 6 additions & 0 deletions kotti/views/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,10 @@ def forbidden_view_html(request):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)
12 changes: 12 additions & 0 deletions kotti/views/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def ch(node):


def includeme_local_navigation(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

# Import is needed in function scope to resolve circular imports caused by
# compatibility imports in slots.py.
from kotti.views.slots import assign_slot
Expand All @@ -60,4 +66,10 @@ def includeme_local_navigation(config):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)
6 changes: 6 additions & 0 deletions kotti/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,4 +612,10 @@ def __call__(self):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)
6 changes: 6 additions & 0 deletions kotti/views/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,10 @@ def notfound_view(context, request):


def includeme(config):
""" Pyramid includeme hook.
:param config: app config
:type config: :class:`pyramid.config.Configurator`
"""

config.scan(__name__)

0 comments on commit 42c36e0

Please sign in to comment.