|
@@ -24,6 +24,11 @@ else:
|
24
|
24
|
#packages
|
25
|
25
|
CTX_PKG = "lodelsites"
|
26
|
26
|
|
|
27
|
+##@brief Reserved context name for loading steps
|
|
28
|
+#@note This context is designed to be set at loading time, allowing lodel2
|
|
29
|
+#main process to use lodel packages
|
|
30
|
+LOAD_CTX = "__loader__"
|
|
31
|
+
|
27
|
32
|
|
28
|
33
|
#
|
29
|
34
|
# Following exception classes are written here to avoid circular dependencies
|
|
@@ -96,6 +101,7 @@ class LodelContext(object):
|
96
|
101
|
##@brief Create a new context
|
97
|
102
|
#@see LodelContext.new()
|
98
|
103
|
def __init__(self, site_id):
|
|
104
|
+ print("Registering new context for '%s'" % site_id)
|
99
|
105
|
if site_id is None:
|
100
|
106
|
#Monosite instanciation
|
101
|
107
|
if self.__class__._type != self.__class__.MONOSITE:
|
|
@@ -251,6 +257,9 @@ initialize it anymore")
|
251
|
257
|
cls._contexts = dict()
|
252
|
258
|
#Add custom MetaPathFinder allowing implementing custom imports
|
253
|
259
|
sys.meta_path = [LodelMetaPathFinder] + sys.meta_path
|
|
260
|
+ #Create and set __loader__ context
|
|
261
|
+ cls.new(LOAD_CTX)
|
|
262
|
+ cls.set(LOAD_CTX)
|
254
|
263
|
else:
|
255
|
264
|
#Add a single context with no site_id
|
256
|
265
|
cls._contexts = cls._current = cls(None)
|
|
@@ -268,6 +277,8 @@ initialize it anymore")
|
268
|
277
|
#@return true if the name is valide else false
|
269
|
278
|
@staticmethod
|
270
|
279
|
def validate_identifier(identifier):
|
|
280
|
+ if identifier == LOAD_CTX:
|
|
281
|
+ return True
|
271
|
282
|
return identifier is None or \
|
272
|
283
|
re.match(r'^[a-zA-Z0-9][a-zA-Z0-9_]', identifier)
|
273
|
284
|
|