author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 12 Sep 2009 21:25:56 +0200 | |
changeset 2908 | 391d57b91615 |
parent 2849 | c0462a1d3958 |
child 2909 | 81eaf0a9101f |
permissions | -rw-r--r-- |
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 |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
115 |
|
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 |
## internal |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
118 |
## |
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 |
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
|
121 |
"""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
|
122 |
|
2359
d4de17ab9a1f
Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2333
diff
changeset
|
123 |
Args: |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
124 |
callback: the callback to retrieve the capability from |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
125 |
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
|
126 |
""" |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
127 |
|
2359
d4de17ab9a1f
Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2333
diff
changeset
|
128 |
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
|
129 |
return False |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
130 |
|
2359
d4de17ab9a1f
Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2333
diff
changeset
|
131 |
func = getattr(callback, service) |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
132 |
|
2359
d4de17ab9a1f
Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2333
diff
changeset
|
133 |
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
|
134 |
return False |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
135 |
|
2359
d4de17ab9a1f
Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2333
diff
changeset
|
136 |
return func |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
137 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
138 |
## |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
139 |
## Core code |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
140 |
## |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
141 |
|
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
142 |
def startNewRequest(self, request): |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
143 |
"""Prepares core to handle a new request. |
2908
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
144 |
|
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
145 |
Args: |
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
146 |
request: a Django HttpRequest object |
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
147 |
""" |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
148 |
|
2849
c0462a1d3958
Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2833
diff
changeset
|
149 |
self.in_request = True |
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
150 |
self.per_request_value = {} |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
151 |
self.setRequestValue('request', request) |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
152 |
|
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
153 |
def endRequest(self, request): |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
154 |
"""Performs cleanup after current request. |
2908
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
155 |
|
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
156 |
Args: |
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
157 |
request: a Django HttpRequest object |
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
158 |
""" |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
159 |
|
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
160 |
old_request = self.getRequestValue('request') |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
161 |
self.per_request_value = {} |
2849
c0462a1d3958
Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2833
diff
changeset
|
162 |
self.in_request = False |
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
163 |
|
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
164 |
if id(old_request) != id(request): |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
165 |
logging.error("ending request: \n'%s'\n != \n'%s'\n" % ( |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
166 |
old_request, request)) |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
167 |
|
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
168 |
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
|
169 |
"""Gets a per-request value. |
2908
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
170 |
|
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
171 |
Args: |
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
172 |
key: the key of the to be retrieved value |
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
173 |
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
|
174 |
""" |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
175 |
|
2849
c0462a1d3958
Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2833
diff
changeset
|
176 |
assert self.in_request |
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
177 |
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
|
178 |
|
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
179 |
def setRequestValue(self, key, value): |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
180 |
"""Sets a per-request value. |
2908
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
181 |
|
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
182 |
Args: |
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
183 |
key: the key of the to be set value |
391d57b91615
Document value store methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2849
diff
changeset
|
184 |
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
|
185 |
""" |
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
186 |
|
2849
c0462a1d3958
Add self.in_request to Core and verify correct state
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2833
diff
changeset
|
187 |
assert self.in_request |
2833
5aa891de5aa5
Add a new per-request value store to Core
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2404
diff
changeset
|
188 |
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
|
189 |
|
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
190 |
def getPatterns(self): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
191 |
"""Returns the Django patterns for this site. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
192 |
""" |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
193 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
194 |
self.callService('registerWithSitemap', True) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
195 |
return defaults.patterns(None, *self.sitemap) |
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 |
@soc.cache.sidebar.cache |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
198 |
def getSidebar(self, id, user): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
199 |
"""Constructs a sidebar for the current user. |
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 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
202 |
self.callService('registerWithSidebar', True) |
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 |
sidebar = [] |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
205 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
206 |
for i in self.sidebar: |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
207 |
menus = i(id, user) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
208 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
209 |
for menu in (menus if menus else []): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
210 |
sidebar.append(menu) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
211 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
212 |
return sorted(sidebar, key=lambda x: x.get('group')) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
213 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
214 |
def callService(self, service, unique, *args, **kwargs): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
215 |
"""Calls the specified service on all callbacks. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
216 |
""" |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
217 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
218 |
if unique and (service in self.services): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
219 |
return |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
220 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
221 |
results = [] |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
222 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
223 |
for callback in self.registered_callbacks: |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
224 |
func = self.getService(callback, service) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
225 |
if not func: |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
226 |
continue |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
227 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
228 |
result = func(*args, **kwargs) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
229 |
results.append(result) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
230 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
231 |
self.services.append(service) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
232 |
return results |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
233 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
234 |
def registerModuleCallbacks(self): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
235 |
"""Retrieves all callbacks for the modules of this site. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
236 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
237 |
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
|
238 |
number are dropped. They won't be called. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
239 |
""" |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
240 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
241 |
fmt = settings.MODULE_FMT |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
242 |
modules = ['soc_core'] + settings.MODULES |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
243 |
modules = [__import__(fmt % i, fromlist=['']) for i in modules] |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
244 |
|
2404
4f87bab3c6b3
Remove getCallback indirection in modules
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
2359
diff
changeset
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
callback_class.API_VERSION) |
2333
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
249 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
250 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
251 |
callback = callback_class(self) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
252 |
self.registered_callbacks.append(callback) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
253 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
254 |
return True |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
255 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
256 |
## |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
257 |
## Module code |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
258 |
## |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
259 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
260 |
def registerCapability(self, capability): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
261 |
"""Registers the specified capability. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
262 |
""" |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
263 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
264 |
self.capabilities.append(capability) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
265 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
266 |
def requireCapability(self, capability): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
267 |
"""Requires that the specified capability is present. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
268 |
""" |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
269 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
270 |
if capability in self.capabilities: |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
271 |
return True |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
272 |
|
2359
d4de17ab9a1f
Style and variable names fixes in soc.modules.core module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2333
diff
changeset
|
273 |
raise MissingCapability(capability, self.capabilities) |
2333
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 |
def requireService(self, service): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
276 |
"""Requires that the specified service has been called. |
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 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
279 |
if service in self.services: |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
280 |
return True |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
281 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
282 |
raise MissingService(service, self.services) |
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 |
def requireUniqueService(self, service): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
285 |
"""Requires that the specified service is called exactly once. |
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 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
288 |
if service not in self.services: |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
289 |
return True |
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 |
raise NonUniqueService(service, self.services) |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
292 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
293 |
def registerSitemapEntry(self, entries): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
294 |
"""Registers the specified entries with the sitemap. |
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 |
|
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
297 |
self.sitemap.extend(entries) |
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 |
def registerSidebarEntry(self, entry): |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
300 |
"""Registers the specified entry with the sidebar. |
221482a54238
First step in the module design
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
diff
changeset
|
301 |
""" |
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 |
self.sidebar.append(entry) |