aboutsummaryrefslogtreecommitdiff
path: root/system/python/spyce/spyceModule.py
blob: 593996b7cde369c271c4e07e6a46cbd1a51c7ea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
##################################################
# SPYCE - Python-based HTML Scripting
# Copyright (c) 2002 Rimon Barr.
#
# Refer to spyce.py
# CVS: $Id$
##################################################

__doc__ = '''Spyce modules functionality.'''

##################################################
# Spyce module
#

class spyceModule:
  "All Spyce module should subclass this."
  def __init__(self, wrapper):
    self._api = wrapper
  def start(self):
    pass
  def finish(self, theError=None):
    pass
  def init(self, *args, **kwargs):
    pass
  def __repr__(self):
    return 'no information, '+str(self.__class__)

class spyceModulePlus(spyceModule):
  def __init__(self, wrapper):
    spyceModule.__init__(self, wrapper)
    self.wrapper = self._api  # deprecated
    self.modules = moduleFinder(wrapper)
    self.globals = wrapper.getGlobals()

class moduleFinder:
  def __init__(self, wrapper):
    self._wrapper = wrapper
  def __getattr__(self, name):
    return self._wrapper.getModule(name)

##################################################
# Spyce module API
#

spyceModuleAPI = [ 'getFilename', 'getCode', 
  'getCodeRefs', 'getModRefs', 
  'getServerObject', 'getServerGlobals', 'getServerID',
  'getModules', 'getModule', 'setModule', 'getGlobals', 
  'registerModuleCallback', 'unregisterModuleCallback',
  'getRequest', 'getResponse', 'setResponse',
  'registerResponseCallback', 'unregisterResponseCallback', 
  'spyceString', 'spyceFile', 'spyceModule', 'spyceTaglib',
  'setStdout', 'getStdout',
]