app/soc/modules/core.py
author Sverre Rabbelier <srabbelier@gmail.com>
Fri, 18 Sep 2009 21:50:54 +0200
changeset 2961 34c6737e77a0
parent 2955 b799af27440e
child 2962 05014496b8f9
permissions -rw-r--r--
Convert cleaning module to use the new checker in core
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     1
# Copyright 2009 the Melange authors.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     2
#
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     3
# Licensed under the Apache License, Version 2.0 (the "License");
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     4
# you may not use this file except in compliance with the License.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     5
# You may obtain a copy of the License at
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     6
#
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     7
#     http://www.apache.org/licenses/LICENSE-2.0
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     8
#
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
     9
# Unless required by applicable law or agreed to in writing, software
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    10
# distributed under the License is distributed on an "AS IS" BASIS,
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    12
# See the License for the specific language governing permissions and
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    13
# limitations under the License.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    14
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    15
"""The Melange Core module.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    16
"""
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    17
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    18
__authors__ = [
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    19
  '"Sverre Rabbelier" <sverre@rabbelier.nl>',
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    20
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    21
  ]
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    22
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    23
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
    24
import logging
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
    25
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    26
from django.conf.urls import defaults
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    27
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    28
import settings
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    29
import soc.cache.sidebar
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    30
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    31
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    32
class Error(Exception):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    33
  """Error class for the callback module.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    34
  """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    35
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    36
  pass
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    37
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    38
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    39
class APIVersionMismatch(Error):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    40
  """Error raised when API version mismatches.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    41
  """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    42
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    43
  MISMATCH_MSG_FMT = "API mismatch, expected '%d', got '%d'."
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    44
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    45
  def __init__(self, expected, actual):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    46
    """Instantiates a new exception with a customized message.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    47
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    48
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    49
    msg = self.MISMATCH_MSG_FMT % (expected, actual)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    50
    super(APIVersionMismatch, self).__init__(msg)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    51
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    52
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    53
class MissingService(Error):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    54
  """Error raised when a required service is missing.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    55
  """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    56
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    57
  MISSING_SERVICE_FMT = "Required service '%s' is not registered, known: %s"
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    58
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    59
  def __init__(self, service, services):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    60
    """Instantiates a new exception with a customized message.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    61
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    62
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    63
    msg = self.MISSING_SERVICE_FMT % (service, services)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    64
    super(MissingService, self).__init__(msg)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    65
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    66
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    67
class MissingCapability(Error):
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    68
  """Error raised when a required capability is missing.
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    69
  """
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    70
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    71
  MISSING_CAPABILITY_FMT = "Required capability '%s' " + \
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    72
      "is not registered, known: %s"
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    73
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    74
  def __init__(self, capability, capabilities):
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    75
    """Instantiates a new exception with a customized message.
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    76
    """
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    77
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    78
    msg = self.MISSING_CAPABILITY_FMT % (capability, capabilities)
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    79
    super(MissingCapability, self).__init__(msg)
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    80
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    81
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    82
class NonUniqueService(Error):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    83
  """Error raised when a required service is missing.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    84
  """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    85
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
    86
  NON_UNIQUE_SERVICE_FMT = "Unique service '%s' called a 2nd time, known: %s."
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    87
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    88
  def __init__(self, service, services):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    89
    """Instantiates a new exception with a customized message.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    90
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    91
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    92
    msg = self.NON_UNIQUE_SERVICE_FMT % (service, services)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    93
    super(NonUniqueService, self).__init__(msg)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    94
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    95
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    96
class Core(object):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    97
  """The core handler that controls the Melange API.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    98
  """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
    99
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   100
  def __init__(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   101
    """Creates a new instance of the Core.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   102
    """
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   103
    
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   104
    # pylint: disable-msg=C0103
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   105
    self.API_VERSION = 1
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   106
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   107
    self.registered_callbacks = []
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   108
    self.capabilities = []
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   109
    self.services = []
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   110
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   111
    self.sitemap = []
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   112
    self.sidebar = []
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   113
    self.per_request_cache = {}
2849
c0462a1d3958 Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2833
diff changeset
   114
    self.in_request = False
2955
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   115
    self.rights = {}
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   116
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   117
  ##
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   118
  ## internal
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   119
  ##
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   120
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   121
  def getService(self, callback, service):
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   122
    """Retrieves the specified service from the callback if supported.
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   123
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   124
    Args:
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   125
     callback: the callback to retrieve the capability from
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   126
     service: the service to retrieve
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   127
    """
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   128
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   129
    if not hasattr(callback, service):
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   130
      return False
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   131
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   132
    func = getattr(callback, service)
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   133
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   134
    if not callable(func):
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   135
      return False
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   136
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   137
    return func
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   138
2954
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   139
  def callService(self, service, unique, *args, **kwargs):
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   140
    """Calls the specified service on all callbacks.
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   141
    """
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   142
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   143
    if unique and (service in self.services):
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   144
      return
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   145
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   146
    results = []
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   147
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   148
    for callback in self.registered_callbacks:
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   149
      func = self.getService(callback, service)
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   150
      if not func:
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   151
        continue
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   152
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   153
      result = func(*args, **kwargs)
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   154
      results.append(result)
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   155
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   156
    self.services.append(service)
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   157
    return results
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   158
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   159
  ##
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   160
  ## Core code
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   161
  ##
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   162
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   163
  def getRequestValue(self, key, default=None):
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   164
    """Gets a per-request value.
2908
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   165
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   166
    Args:
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   167
      key: the key of the to be retrieved value
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   168
      default: the default value (returned if no value is set)
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   169
    """
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   170
2849
c0462a1d3958 Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2833
diff changeset
   171
    assert self.in_request
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   172
    return self.per_request_value.get(key, default)
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   173
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   174
  def setRequestValue(self, key, value):
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   175
    """Sets a per-request value.
2908
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   176
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   177
    Args:
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   178
      key: the key of the to be set value
391d57b91615 Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2849
diff changeset
   179
      value: the value that should be set
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   180
    """
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   181
2849
c0462a1d3958 Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2833
diff changeset
   182
    assert self.in_request
2833
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   183
    self.per_request_value[key] = value
5aa891de5aa5 Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2404
diff changeset
   184
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   185
  def getPatterns(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   186
    """Returns the Django patterns for this site.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   187
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   188
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   189
    self.callService('registerWithSitemap', True)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   190
    return defaults.patterns(None, *self.sitemap)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   191
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   192
  @soc.cache.sidebar.cache
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   193
  def getSidebar(self, id, user):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   194
    """Constructs a sidebar for the current user.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   195
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   196
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   197
    self.callService('registerWithSidebar', True)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   198
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   199
    sidebar = []
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   200
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   201
    for i in self.sidebar:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   202
      menus = i(id, user)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   203
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   204
      for menu in (menus if menus else []):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   205
        sidebar.append(menu)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   206
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   207
    return sorted(sidebar, key=lambda x: x.get('group'))
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   208
2955
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   209
  def getRightsChecker(self, prefix):
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   210
    """Returns a rights checker for this site.
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   211
    """
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   212
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   213
    from soc.logic import rights as rights_logic
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   214
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   215
    self.callService('registerRights', True)
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   216
    return rights_logic.Checker(self.rights, prefix)
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   217
2954
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   218
  ###
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   219
  ### Core control code
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   220
  ###
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   221
  ### Called by other setup code to get the Core in a desired state.
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   222
  ###
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   223
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   224
  def startNewRequest(self, request):
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   225
    """Prepares core to handle a new request.
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   226
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   227
    Args:
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   228
      request: a Django HttpRequest object
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   229
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   230
2954
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   231
    self.in_request = True
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   232
    self.per_request_value = {}
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   233
    self.setRequestValue('request', request)
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   234
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   235
  def endRequest(self, request, optional):
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   236
    """Performs cleanup after current request.
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   237
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   238
    Args:
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   239
      request: a Django HttpRequest object
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   240
      optional: whether to noop when not in a request
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   241
    """
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   242
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   243
    # already cleaned up, as expected
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   244
    if optional and not self.in_request:
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   245
      return
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   246
2954
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   247
    old_request = self.getRequestValue('request')
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   248
    self.per_request_value = {}
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   249
    self.in_request = False
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   250
2954
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   251
    if id(old_request) != id(request):
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   252
      logging.error("ending request: \n'%s'\n != \n'%s'\n" % (
9ea3b04d929c Move around Core methods into more relevant sections
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2909
diff changeset
   253
          old_request, request))
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   254
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   255
  def registerModuleCallbacks(self):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   256
    """Retrieves all callbacks for the modules of this site.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   257
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   258
    Callbacks for modules without a version number or the wrong API_VERSION
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   259
    number are dropped.  They won't be called.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   260
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   261
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   262
    fmt = settings.MODULE_FMT
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   263
    modules = ['soc_core'] + settings.MODULES
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   264
    modules = [__import__(fmt % i, fromlist=['']) for i in modules]
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   265
2404
4f87bab3c6b3 Remove getCallback indirection in modules
Sverre Rabbelier <sverre@rabbelier.nl>
parents: 2359
diff changeset
   266
    for callback_class in [i.Callback for i in modules]:
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   267
      if callback_class.API_VERSION != self.API_VERSION:
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   268
        raise APIVersionMismatch(self.API_VERSION,
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   269
                                 callback_class.API_VERSION)
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   270
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   271
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   272
      callback = callback_class(self)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   273
      self.registered_callbacks.append(callback)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   274
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   275
    return True
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   276
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   277
  ##
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   278
  ## Module code
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   279
  ##
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   280
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   281
  def registerCapability(self, capability):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   282
    """Registers the specified capability.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   283
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   284
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   285
    self.capabilities.append(capability)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   286
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   287
  def requireCapability(self, capability):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   288
    """Requires that the specified capability is present.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   289
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   290
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   291
    if capability in self.capabilities:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   292
      return True
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   293
2359
d4de17ab9a1f Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 2333
diff changeset
   294
    raise MissingCapability(capability, self.capabilities)
2333
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   295
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   296
  def requireService(self, service):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   297
    """Requires that the specified service has been called.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   298
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   299
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   300
    if service in self.services:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   301
      return True
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   302
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   303
    raise MissingService(service, self.services)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   304
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   305
  def requireUniqueService(self, service):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   306
    """Requires that the specified service is called exactly once.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   307
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   308
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   309
    if service not in self.services:
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   310
      return True
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   311
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   312
    raise NonUniqueService(service, self.services)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   313
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   314
  def registerSitemapEntry(self, entries):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   315
    """Registers the specified entries with the sitemap.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   316
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   317
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   318
    self.sitemap.extend(entries)
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   319
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   320
  def registerSidebarEntry(self, entry):
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   321
    """Registers the specified entry with the sidebar.
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   322
    """
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   323
221482a54238 First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff changeset
   324
    self.sidebar.append(entry)
2955
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   325
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   326
  def registerRight(self, key, value):
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   327
    """Registers the specified right.
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   328
    """
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   329
b799af27440e Add document rights registration to core
Sverre Rabbelier <srabbelier@gmail.com>
parents: 2954
diff changeset
   330
    self.rights[key] = value