App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
google.appengine.tools.dev_appserver_import_hook.FakeFile Class Reference
Inheritance diagram for google.appengine.tools.dev_appserver_import_hook.FakeFile:

Public Member Functions

def __init__
 

Static Public Member Functions

def SetAllowedPaths
 
def SetAllowSkippedFiles
 
def SetAllowedModule
 
def SetSkippedFiles
 
def SetStaticFileConfigMatcher
 
def IsFileAccessible
 

Static Public Attributes

tuple ALLOWED_MODES = frozenset(['r', 'rb', 'U', 'rU'])
 
tuple ALLOWED_FILES
 
tuple ALLOWED_FILES_RE = set([re.compile(r'.*/python27.zip$')])
 
tuple ALLOWED_DIRS
 
tuple os_source_location = inspect.getsourcefile(os)
 
tuple NOT_ALLOWED_DIRS
 
tuple ALLOWED_SITE_PACKAGE_DIRS
 
tuple ALLOWED_SITE_PACKAGE_FILES
 

Detailed Description

File sub-class that enforces the security restrictions of the production
environment.

Constructor & Destructor Documentation

def google.appengine.tools.dev_appserver_import_hook.FakeFile.__init__ (   self,
  filename,
  mode = 'r',
  bufsize = -1,
  kwargs 
)
Initializer. See file built-in documentation.

Member Function Documentation

def google.appengine.tools.dev_appserver_import_hook.FakeFile.IsFileAccessible (   filename,
  normcase = os.path.normcase,
  py27_optional = False 
)
static
Determines if a file's path is accessible.

SetAllowedPaths(), SetSkippedFiles() and SetStaticFileConfigMatcher() must
be called before this method or else all file accesses will raise an error.

Args:
  filename: Path of the file to check (relative or absolute). May be a
directory, in which case access for files inside that directory will
be checked.
  normcase: Used for dependency injection.
  py27_optional: Whether the filename being checked matches the name of an
optional python27 runtime library.

Returns:
  True if the file is accessible, False otherwise.
def google.appengine.tools.dev_appserver_import_hook.FakeFile.SetAllowedModule (   name)
static
Allow the use of a module based on where it is located.

Meant to be used by use_library() so that it has a link back into the
trusted part of the interpreter.

Args:
  name: Name of the module to allow.
def google.appengine.tools.dev_appserver_import_hook.FakeFile.SetAllowedPaths (   root_path,
  application_paths 
)
static
Configures which paths are allowed to be accessed.

Must be called at least once before any file objects are created in the
hardened environment.

Args:
  root_path: Absolute path to the root of the application.
  application_paths: List of additional paths that the application may
                 access, this must include the App Engine runtime but
                 not the Python library directories.
def google.appengine.tools.dev_appserver_import_hook.FakeFile.SetAllowSkippedFiles (   allow_skipped_files)
static
Configures access to files matching FakeFile._skip_files.

Args:
  allow_skipped_files: Boolean whether to allow access to skipped files
def google.appengine.tools.dev_appserver_import_hook.FakeFile.SetSkippedFiles (   skip_files)
static
Sets which files in the application directory are to be ignored.

Must be called at least once before any file objects are created in the
hardened environment.

Must be called whenever the configuration was updated.

Args:
  skip_files: Object with .match() method (e.g. compiled regexp).
def google.appengine.tools.dev_appserver_import_hook.FakeFile.SetStaticFileConfigMatcher (   static_file_config_matcher)
static
Sets StaticFileConfigMatcher instance for checking if a file is static.

Must be called at least once before any file objects are created in the
hardened environment.

Must be called whenever the configuration was updated.

Args:
  static_file_config_matcher: StaticFileConfigMatcher instance.

Member Data Documentation

tuple google.appengine.tools.dev_appserver_import_hook.FakeFile.ALLOWED_DIRS
static
Initial value:
1 = set([
2  os.path.normcase(os.path.realpath(os.path.dirname(os.__file__))),
3  os.path.normcase(os.path.abspath(os.path.dirname(os.__file__))),
4  os.path.normcase(os.path.dirname(os.path.realpath(os.__file__))),
5  os.path.normcase(os.path.dirname(os.path.abspath(os.__file__))),
6  ])
tuple google.appengine.tools.dev_appserver_import_hook.FakeFile.ALLOWED_FILES
static
Initial value:
1 = set(os.path.normcase(filename)
2  for filename in mimetypes.knownfiles
3  if os.path.isfile(filename))
tuple google.appengine.tools.dev_appserver_import_hook.FakeFile.ALLOWED_SITE_PACKAGE_DIRS
static
Initial value:
1 = set(
2  os.path.normcase(os.path.abspath(os.path.join(SITE_PACKAGES, path)))
3  for path in [
4 
5  ])
tuple google.appengine.tools.dev_appserver_import_hook.FakeFile.NOT_ALLOWED_DIRS
static
Initial value:
1 = set([
2 
3 
4 
5 
6  SITE_PACKAGES,
7  ])

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