Back to index

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

List of all members.

Public Member Functions

def __render_with_namespace__
def __call__
def ZScriptHTML_tryParams
def read
def document_src
def PrincipiaSearchSource
def params
def body
def get_size
def manage_FTPget
def func_defaults
def func_code
def title
def getBindingAssignments

Public Attributes

 func_code
 func_defaults
 title

Static Public Attributes

string meta_type = 'Filesystem Script (Python)'
tuple manage_options
tuple security = ClassSecurityInfo()
tuple manage_main = DTMLFile('custpy', _dtmldir)
 manage_haveProxy = PythonScript.manage_haveProxy.im_func
tuple func_defaults = ComputedAttribute(func_defaults, 1)
tuple func_code = ComputedAttribute(func_code, 1)
tuple title = ComputedAttribute(title, 1)

Private Member Functions

def _createZODBClone
def _readFile
def _validateProxy
def _exec
 The following is mainly taken from PythonScript.py ###.
def _write

Private Attributes

 _body
 _params
 _source

Static Private Attributes

string _params = ''
 _v_f = None
tuple _proxy_roles = ()
 _owner = None

Detailed Description

FSPythonScripts act like Python Scripts but are not directly
modifiable from the management interface.

Definition at line 86 of file FSPythonScript.py.


Member Function Documentation

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

Definition at line 137 of file FSPythonScript.py.

00137 
00138     def __call__(self, *args, **kw):
00139         '''Calls the script.'''
00140         self._updateFromFS()
00141         return Script.__call__(self, *args, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Calls the script.

Definition at line 132 of file FSPythonScript.py.

00132 
00133     def __render_with_namespace__(self, namespace):
00134         '''Calls the script.'''
00135         self._updateFromFS()
00136         return Script.__render_with_namespace__(self, namespace)

Here is the call graph for this function:

Create a ZODB (editable) equivalent of this object.

Definition at line 113 of file FSPythonScript.py.

00113 
00114     def _createZODBClone(self):
00115         """Create a ZODB (editable) equivalent of this object."""
00116         return CustomizedPythonScript(self.getId(), self.read())

def CMFCore.FSPythonScript.FSPythonScript._exec (   self,
  bound_names,
  args,
  kw 
) [private]

The following is mainly taken from PythonScript.py ###.

Call a Python Script

Calling a Python Script is an actual function invocation.

Definition at line 144 of file FSPythonScript.py.

00144 
00145     def _exec(self, bound_names, args, kw):
00146         """Call a Python Script
00147 
00148         Calling a Python Script is an actual function invocation.
00149         """
00150         # do caching
00151         keyset = None
00152         if self.ZCacheable_isCachingEnabled():
00153             # Prepare a cache key.
00154             keyset = kw.copy()
00155             asgns = self.getBindingAssignments()
00156             name_context = asgns.getAssignedName('name_context', None)
00157             if name_context:
00158                 keyset[name_context] = self.aq_parent.getPhysicalPath()
00159             name_subpath = asgns.getAssignedName('name_subpath', None)
00160             if name_subpath:
00161                 keyset[name_subpath] = self._getTraverseSubpath()
00162             # Note: perhaps we should cache based on name_ns also.
00163             keyset['*'] = args
00164             result = self.ZCacheable_get(keywords=keyset, default=_marker)
00165             if result is not _marker:
00166                 # Got a cached value.
00167                 return result
00168 
00169         # Prepare the function.
00170         f = self._v_f
00171         if f is None:
00172             # The script has errors.
00173             __traceback_supplement__ = (
00174                 FSPythonScriptTracebackSupplement, self, 0)
00175             raise RuntimeError, '%s has errors.' % self._filepath
00176 
00177         # Updating func_globals directly is not thread safe here.
00178         # In normal PythonScripts, every thread has its own
00179         # copy of the function.  But in FSPythonScripts
00180         # there is only one copy.  So here's another way.
00181         new_globals = f.func_globals.copy()
00182         new_globals['__traceback_supplement__'] = (
00183             FSPythonScriptTracebackSupplement, self)
00184         new_globals['__file__'] = self._filepath
00185         if bound_names:
00186             new_globals.update(bound_names)
00187         if f.func_defaults:
00188             f = new.function(f.func_code, new_globals, f.func_name,
00189                              f.func_defaults)
00190         else:
00191             f = new.function(f.func_code, new_globals, f.func_name)
00192 
00193         # Execute the function in a new security context.
00194         security=getSecurityManager()
00195         security.addContext(self)
00196         try:
00197             result = f(*args, **kw)
00198             if keyset is not None:
00199                 # Store the result in the cache.
00200                 self.ZCacheable_set(result, keywords=keyset)
00201             return result
00202         finally:
00203             security.removeContext(self)

Here is the call graph for this function:

def CMFCore.FSPythonScript.FSPythonScript._readFile (   self,
  reparse 
) [private]
Read the data from the filesystem.

Definition at line 117 of file FSPythonScript.py.

00117 
00118     def _readFile(self, reparse):
00119         """Read the data from the filesystem.
00120         """
00121         file = open(self._filepath, 'rU')
00122         try:
00123             data = file.read()
00124         finally:
00125             file.close()
00126 
00127         if reparse:
00128             self._write(data, reparse)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.FSPythonScript.FSPythonScript._validateProxy (   self,
  roles = None 
) [private]

Definition at line 129 of file FSPythonScript.py.

00129 
00130     def _validateProxy(self, roles=None):
00131         pass

Here is the caller graph for this function:

def CMFCore.FSPythonScript.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 255 of file FSPythonScript.py.

00255 
00256     def _write(self, text, compile):
00257         '''
00258         Parses the source, storing the body, params, title, bindings,
00259         and source in self.  If compile is set, compiles the
00260         function.
00261         '''
00262         ps = PythonScript(self.id)
00263         ps.write(text)
00264         if compile:
00265             ps._makeFunction(1)
00266             self._v_f = f = ps._v_f
00267             if f is not None:
00268                 self.func_code = f.func_code
00269                 self.func_defaults = f.func_defaults
00270             else:
00271                 # There were errors in the compile.
00272                 # No signature.
00273                 self.func_code = bad_func_code()
00274                 self.func_defaults = None
00275         self._body = ps._body
00276         self._params = ps._params
00277         self.title = ps.title
00278         self._setupBindings(ps.getBindingAssignments().getAssignedNames())
00279         self._source = ps.read()  # Find out what the script sees.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 244 of file FSPythonScript.py.

00244 
00245     def body(self): return self._body

def CMFCore.FSPythonScript.FSPythonScript.document_src (   self,
  REQUEST = None,
  RESPONSE = None 
)
Return unprocessed document source.

Definition at line 225 of file FSPythonScript.py.

00225 
00226     def document_src(self, REQUEST=None, RESPONSE=None):
00227         """Return unprocessed document source."""
00228 
00229         if RESPONSE is not None:
00230             RESPONSE.setHeader('Content-Type', 'text/plain')
00231         return self._source

Definition at line 288 of file FSPythonScript.py.

00288 
00289     def func_code(self):
00290         # See func_defaults.
00291         self._updateFromFS()
        return self.__dict__.get('func_code', None)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 280 of file FSPythonScript.py.

00280 
00281     def func_defaults(self):
00282         # This ensures func_code and func_defaults are
00283         # set when the code hasn't been compiled yet,
00284         # just in time for mapply().  Truly odd, but so is mapply(). :P
00285         self._updateFromFS()
        return self.__dict__.get('func_defaults', None)

Here is the call graph for this function:

Definition at line 247 of file FSPythonScript.py.

00247 
00248     def get_size(self): return len(self.read())

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 300 of file FSPythonScript.py.

00300 
00301     def getBindingAssignments(self):
00302         # Override of the version in Bindings.py.
00303         # This version ensures that bindings get loaded on demand.
00304         if not hasattr(self, '_bind_names'):
00305             # Set a default first to avoid recursion
00306             self._setupBindings()
00307             # Now do it for real
00308             self._updateFromFS()
00309         return self._bind_names
00310 
00311 InitializeClass(FSPythonScript)
00312 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 250 of file FSPythonScript.py.

00250 
00251     def manage_FTPget(self):
00252         "Get source for FTP download"
00253         self.REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
00254         return self.read()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 238 of file FSPythonScript.py.

00238 
00239     def params(self): return self._params

Definition at line 233 of file FSPythonScript.py.

00233 
00234     def PrincipiaSearchSource(self):
00235         "Support for searching - the document's contents are searched."
00236         return "%s\n%s" % (self._params, self._body)

Definition at line 220 of file FSPythonScript.py.

00220 
00221     def read(self):
00222         self._updateFromFS()
00223         return self._source

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 294 of file FSPythonScript.py.

00294 
00295     def title(self):
00296         # See func_defaults.
00297         self._updateFromFS()
        return self.__dict__.get('title', None)

Here is the call graph for this function:

Here is the caller graph for this function:

Parameters to test the script with.

Definition at line 210 of file FSPythonScript.py.

00210 
00211     def ZScriptHTML_tryParams(self):
00212         """Parameters to test the script with."""
00213         param_names = []
00214         for name in self._params.split(','):
00215             name = name.strip()
00216             if name and name[0] != '*':
00217                 param_names.append( name.split('=', 1)[0] )
00218         return param_names


Member Data Documentation

Definition at line 274 of file FSPythonScript.py.

Definition at line 95 of file FSPythonScript.py.

string CMFCore.FSPythonScript.FSPythonScript._params = '' [static, private]

Definition at line 92 of file FSPythonScript.py.

Definition at line 275 of file FSPythonScript.py.

Definition at line 94 of file FSPythonScript.py.

Definition at line 278 of file FSPythonScript.py.

Definition at line 93 of file FSPythonScript.py.

Definition at line 267 of file FSPythonScript.py.

tuple CMFCore.FSPythonScript.FSPythonScript.func_code = ComputedAttribute(func_code, 1) [static]

Definition at line 292 of file FSPythonScript.py.

Definition at line 268 of file FSPythonScript.py.

Definition at line 286 of file FSPythonScript.py.

CMFCore.FSPythonScript.FSPythonScript.manage_haveProxy = PythonScript.manage_haveProxy.im_func [static]

Definition at line 241 of file FSPythonScript.py.

tuple CMFCore.FSPythonScript.FSPythonScript.manage_main = DTMLFile('custpy', _dtmldir) [static]

Definition at line 106 of file FSPythonScript.py.

Initial value:
({'label':'Customize', 'action':'manage_main'},
                      {'label':'Test', 'action':'ZScriptHTML_tryForm',
                       'help': ('PythonScripts', 'PythonScript_test.stx')},
                     )

Definition at line 97 of file FSPythonScript.py.

string CMFCore.FSPythonScript.FSPythonScript.meta_type = 'Filesystem Script (Python)' [static]

Definition at line 91 of file FSPythonScript.py.

tuple CMFCore.FSPythonScript.FSPythonScript.security = ClassSecurityInfo() [static]

Definition at line 102 of file FSPythonScript.py.

Definition at line 276 of file FSPythonScript.py.

tuple CMFCore.FSPythonScript.FSPythonScript.title = ComputedAttribute(title, 1) [static]

Definition at line 298 of file FSPythonScript.py.


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