Back to index

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

List of all members.

Public Member Functions

def __call__
def write

Public Attributes

 func_code
 func_defaults
 title
 id

Static Public Attributes

 write = PythonScript.write

Private Member Functions

def _createZODBClone
def _write
def _metadata_map

Private Attributes

 _v_f
 _body
 _params
 _source

Static Private Attributes

 _setupBindings = PythonScript._setupBindings
 _metadata_map = PythonScript._metadata_map

Detailed Description

Definition at line 135 of file Script.py.


Member Function Documentation

def CMFFormController.Script.FSPythonScript.__call__ (   self,
  args,
  kw 
)
Calls the script.

Definition at line 142 of file Script.py.

00142 
00143     def __call__(self, *args, **kw):
00144         '''Calls the script.'''
00145         self._updateFromFS()
00146         return BaseFSPythonScript.__call__(self, *args, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Create a ZODB (editable) equivalent of this object.

Definition at line 136 of file Script.py.

00136 
00137     def _createZODBClone(self):
00138         """Create a ZODB (editable) equivalent of this object."""
00139         obj = PythonScript(self.getId(), filepath=self._filepath)
00140         obj.write(self.read())
00141         return obj

Reimplemented from CMFFormController.Script.PythonScript.

Definition at line 172 of file Script.py.

00172 
00173     def _metadata_map(self):
00174         m = {
00175             'title': self.title,
00176             'parameters': self._params,
00177            }
00178         bindmap = self.getBindingAssignments().getAssignedNames()
00179         for k, v in _nice_bind_names.items():
00180             m['bind '+k] = bindmap.get(v, '')
00181         return m

Here is the call graph for this function:

def CMFFormController.Script.FSPythonScript._write (   self,
  text,
  compile 
) [private]
Parses the source, storing the body, params, title, bindings,
and source in self.  If compile is set, compiles the
function.

Definition at line 147 of file Script.py.

00147 
00148     def _write(self, text, compile):
00149         '''
00150         Parses the source, storing the body, params, title, bindings,
00151         and source in self.  If compile is set, compiles the
00152         function.
00153         '''
00154         ps = PythonScript(self.id, filepath=self._filepath)
00155         ps.write(text)
00156         if compile:
00157             ps._makeFunction(1)
00158             self._v_f = f = ps._v_f
00159             if f is not None:
00160                 self.func_code = f.func_code
00161                 self.func_defaults = f.func_defaults
00162             else:
00163                 # There were errors in the compile.
00164                 # No signature.
00165                 self.func_code = bad_func_code()
00166                 self.func_defaults = None
00167         self._body = ps._body
00168         self._params = ps._params
00169         self.title = ps.title
00170         self._setupBindings(ps.getBindingAssignments().getAssignedNames())
00171         self._source = ps.read()  # Find out what the script sees.

def CMFFormController.Script.PythonScript.write (   self,
  text 
) [inherited]
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

Reimplemented from CMFFormController.Script.PythonScript.

Definition at line 166 of file Script.py.

Definition at line 183 of file Script.py.

Reimplemented from CMFFormController.Script.PythonScript.

Definition at line 167 of file Script.py.

Definition at line 182 of file Script.py.

Definition at line 170 of file Script.py.

Definition at line 157 of file Script.py.

Definition at line 159 of file Script.py.

Definition at line 160 of file Script.py.

Definition at line 53 of file Script.py.

Reimplemented from CMFFormController.Script.PythonScript.

Definition at line 168 of file Script.py.

Definition at line 184 of file Script.py.


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