Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
CMFFormController.Script.PythonScript Class Reference
Inheritance diagram for CMFFormController.Script.PythonScript:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def write

Public Attributes

 id
 title

Private Member Functions

def _setupBindings
def _metadata_map

Private Attributes

 _filepath
 _bind_names
 _params
 _body

Detailed Description

Definition at line 50 of file Script.py.


Constructor & Destructor Documentation

def CMFFormController.Script.PythonScript.__init__ (   self,
  id,
  filepath = None 
)

Definition at line 52 of file Script.py.

00052 
00053     def __init__(self, id, filepath=None):
00054         self.id = id
00055         self._filepath = filepath
00056         self.ZBindings_edit(defaultBindings)
00057         self._makeFunction()


Member Function Documentation

Reimplemented in CMFFormController.Script.FSPythonScript.

Definition at line 62 of file Script.py.

00062 
00063     def _metadata_map(self):
00064         m = {
00065             'title': self.title,
00066             'parameters': self._params,
00067            }
00068         bindmap = self.getBindingAssignments().getAssignedNames()
00069         for k, v in _nice_bind_names.items():
00070             m['bind '+k] = bindmap.get(v, '')
00071         return m

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFFormController.Script.PythonScript._setupBindings (   self,
  names = {} 
) [private]

Definition at line 58 of file Script.py.

00058 
00059     def _setupBindings(self, names={}):
00060         self._bind_names = names = NameAssignments(names)
00061         return names

Here is the caller graph for this function:

def CMFFormController.Script.PythonScript.write (   self,
  text 
)
Change the Script by parsing a read()-style source text. 

Definition at line 72 of file Script.py.

00072 
00073     def write(self, text):
00074         """ Change the Script by parsing a read()-style source text. """
00075         self._validateProxy()
00076         mdata = self._metadata_map()
00077         bindmap = self.getBindingAssignments().getAssignedNames()
00078         bup = 0
00079 
00080         st = 0
00081         try:
00082             while 1:
00083                 # Find the next non-empty line
00084                 m = _nonempty_line.search(text, st)
00085                 if not m:
00086                     # There were no non-empty body lines
00087                     body = ''
00088                     break
00089                 line = m.group(0).strip()
00090                 if line[:2] != '##':
00091                     # We have found the first line of the body
00092                     body = text[m.start(0):]
00093                     break
00094 
00095                 st = m.end(0)
00096                 # Parse this header line
00097                 if len(line) == 2 or line[2] == ' ' or '=' not in line:
00098                     # Null header line
00099                     continue
00100                 k, v = line[2:].split('=', 1)
00101                 k = k.strip().lower()
00102                 v = v.strip()
00103                 if not mdata.has_key(k):
00104                     raise SyntaxError('Unrecognized header line "%s" in file %s' % (line, self._filepath))
00105                 if v == mdata[k]:
00106                     # Unchanged value
00107                     continue
00108 
00109                 # Set metadata value
00110                 if k == 'title':
00111                     self.title = v
00112                 elif k == 'parameters':
00113                     self._params = v
00114                 elif k[:5] == 'bind ':
00115                     bindmap[_nice_bind_names[k[5:]]] = v
00116                     bup = 1
00117 
00118             body = body.rstrip()
00119             if body:
00120                 body = body + '\n'
00121             if body != self._body:
00122                 self._body = body
00123             if bup:
00124                 self.ZBindings_edit(bindmap)
00125             else:
00126                 self._makeFunction()
00127         except (ConflictError, KeyboardInterrupt):
00128             raise
00129         except:
00130             logger.exception('%s write failed' % self.meta_type)
00131             raise
00132 
00133 Globals.InitializeClass(PythonScript)
00134 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 59 of file Script.py.

Reimplemented in CMFFormController.Script.FSPythonScript.

Definition at line 121 of file Script.py.

Definition at line 54 of file Script.py.

Reimplemented in CMFFormController.Script.FSPythonScript.

Definition at line 112 of file Script.py.

Definition at line 53 of file Script.py.

Reimplemented in CMFFormController.Script.FSPythonScript.

Definition at line 110 of file Script.py.


The documentation for this class was generated from the following file: