Skip to content

Commit

Permalink
Merge pull request #157 from 7wonders/master
Browse files Browse the repository at this point in the history
Adds an RAISE_ITEMS_ERRORS_ON_DEBUG setting.
  • Loading branch information
idlesign committed Jul 1, 2015
2 parents a7900b4 + 778e3e1 commit a626559
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/source/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,13 @@ Usage example::
{% sitetree_page_description from "mytree" %}

This command renders current page description from tree named 'mytree'.



.. _tag-ignore-errors:
RAISE_ITEMS_ERRORS_ON_DEBUG
---------------------------

DEFAULT: True

There are some rare occasions when you want to turn off errors that are thrown by sitetree even during debug. Setting RAISE_ITEMS_ERRORS_ON_DEBUG = False will turn them off.
2 changes: 2 additions & 0 deletions sitetree/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

UNRESOLVED_ITEM_MARKER = getattr(settings, 'SITETREE_UNRESOLVED_ITEM_MARKER', u'#unresolved')

RAISE_ITEMS_ERRORS_ON_DEBUG = getattr(settings, 'RAISE_ITEMS_ERRORS_ON_DEBUG', True)

# Reserved tree items aliases.
ALIAS_TRUNK = 'trunk'
ALIAS_THIS_CHILDREN = 'this-children'
Expand Down
4 changes: 2 additions & 2 deletions sitetree/sitetreeapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .utils import get_tree_model, get_tree_item_model, import_app_sitetree_module, generate_id_for
from .settings import (
ALIAS_TRUNK, ALIAS_THIS_CHILDREN, ALIAS_THIS_SIBLINGS, ALIAS_THIS_PARENT_SIBLINGS, ALIAS_THIS_ANCESTOR_CHILDREN,
UNRESOLVED_ITEM_MARKER)
UNRESOLVED_ITEM_MARKER, RAISE_ITEMS_ERRORS_ON_DEBUG)


MODEL_TREE_CLASS = get_tree_model()
Expand Down Expand Up @@ -613,7 +613,7 @@ def get_current_page_attr(self, attr_name, tree_alias, context):
current_item = self.get_tree_current_item(tree_alias)
# Current item is unresolved, fail silently.
if current_item is None:
if settings.DEBUG:
if settings.DEBUG and RAISE_ITEMS_ERRORS_ON_DEBUG:
raise SiteTreeError(
'Unable to resolve current sitetree item to get a `%s` for current page. Check whether '
'there is an appropriate sitetree item defined for current URL.' % attr_name)
Expand Down

0 comments on commit a626559

Please sign in to comment.