コード例 #1
0
 def ProcessClassLoaderConfigNode(self, node):
   for node in xml_parser_utils.GetNodes(node, 'priority-specifier'):
     entry = PrioritySpecifierEntry()
     entry.filename = xml_parser_utils.GetAttribute(node, 'filename')
     if not entry.filename:
       self.errors.append('Filename needs to be provided for each '
                          'priority specifier')
     elif self.app_engine_web_xml.SpecifierEnteredAlready(entry.filename):
       self.errors.append('Cannot have more than one priority specifier with '
                          'the same filename: %s' % entry.filename)
     else:
       try:
         priority = xml_parser_utils.GetAttribute(node, 'priority')
         entry.priority = float(priority) if priority else 1.0
       except ValueError:
         self.errors.append('priority-specifiers must be numbers')
       self.app_engine_web_xml.class_loader_config.append(entry)
コード例 #2
0
    def ProcessBackendNode(self, node):
        """Processes XML nodes labeled 'backend' into a Backends object."""
        tag = xml_parser_utils.GetTag(node)
        if tag != 'backend':
            self.errors.append('Unrecognized node: <%s>' % tag)
            return

        backend = Backend()
        name = xml_parser_utils.GetAttribute(node, 'name')
        if not name:
            self.errors.append('All backends must have names')
            backend.name = '-'
        else:
            backend.name = name
        instance_class = xml_parser_utils.GetChildNodeText(node, 'class')
        if instance_class:
            backend.instance_class = instance_class
        instances = xml_parser_utils.GetChildNodeText(node, 'instances')
        if instances:
            try:
                backend.instances = int(instances)
            except ValueError:
                self.errors.append(
                    '<instances> must be an integer (bad value %s) in backend %s'
                    % (instances, backend.name))
        max_concurrent_requests = xml_parser_utils.GetChildNodeText(
            node, 'max-concurrent-requests')
        if max_concurrent_requests:
            try:
                backend.max_concurrent_requests = int(max_concurrent_requests)
            except ValueError:
                self.errors.append(
                    '<max-concurrent-requests> must be an integer '
                    '(bad value %s) in backend %s' %
                    (max_concurrent_requests, backend.name))

        options_node = xml_parser_utils.GetChild(node, 'options')
        if options_node is not None:
            for sub_node in options_node.getchildren():
                tag = xml_parser_utils.GetTag(sub_node)
                if tag not in ('fail-fast', 'dynamic', 'public'):
                    self.errors.append(
                        '<options> only supports values fail-fast, '
                        'dynamic, and public (bad value %s) in backend %s' %
                        (tag, backend.name))
                    continue
                tag = tag.replace('-', '')
                if xml_parser_utils.BooleanValue(sub_node.text):
                    backend.options.add(tag)
                else:
                    if tag in backend.options:
                        backend.options.remove(tag)

        self.backends.append(backend)
コード例 #3
0
  def ProcessStaticFilesNode(self, node):
    """Processes files according to filetype."""
    for sub_node in xml_parser_utils.GetNodes(node, 'include'):
      path = xml_parser_utils.GetAttribute(sub_node, 'path').strip()
      expiration = xml_parser_utils.GetAttribute(sub_node, 'expiration').strip()
      static_file_include = StaticFileInclude(path, expiration, {})

      for http_header_node in xml_parser_utils.GetNodes(
          sub_node, 'http-header'):
        name = xml_parser_utils.GetAttribute(http_header_node, 'name')
        value = xml_parser_utils.GetAttribute(http_header_node, 'value')

        if name in static_file_include.http_headers:
          self.errors.append('Headers can only be entered once; %s entered '
                             'more than once' % name)
        static_file_include.http_headers[name] = value
      self.app_engine_web_xml.static_file_includes.append(static_file_include)

    for sub_node in xml_parser_utils.GetNodes(node, 'exclude'):
      path = xml_parser_utils.GetAttribute(sub_node, 'path').strip()
      self.app_engine_web_xml.static_file_excludes.append(path)
コード例 #4
0
    def ProcessIndexNode(self, node):
        """Processes XML <datastore-index> nodes into Index objects.

    The following information is parsed out:
    kind: specifies the kind of entities to index.
    ancestor: true if the index supports queries that filter by
      ancestor-key to constraint results to a single entity group.
    property: represents the entity properties to index, with a name
      and direction attribute.

    Args:
      node: <datastore-index> XML node in datastore-indexes.xml.
    """
        tag = xml_parser_utils.GetTag(node)
        if tag != 'datastore-index':
            self.errors.append('Unrecognized node: <%s>' % tag)
            return

        index = Index()
        index.kind = xml_parser_utils.GetAttribute(node, 'kind')
        if not index.kind:
            self.errors.append(MISSING_KIND)
        index.ancestor = xml_parser_utils.BooleanValue(
            xml_parser_utils.GetAttribute(node, 'ancestor'))
        index.properties = OrderedDict()
        for property_node in xml_parser_utils.GetNodes(node, 'property'):
            name = xml_parser_utils.GetAttribute(property_node, 'name')
            if not name:
                self.errors.append(NAME_MISSING % index.kind)
                continue

            direction = (xml_parser_utils.GetAttribute(property_node,
                                                       'direction') or 'asc')
            if direction not in ('asc', 'desc'):
                self.errors.append(BAD_DIRECTION % direction)
                continue
            index.properties[name] = direction
        self.indexes.append(index)
コード例 #5
0
    def _ProcessUrlMappingNode(self, node):
        """Parses out URL and possible ID for filter-mapping and servlet-mapping.

    Pulls url-pattern text out of node and adds to WebXml object. If url-pattern
    has an id attribute, adds that as well. This is done for <servlet-mapping>
    and <filter-mapping> nodes.

    Args:
      node: An ElementTreeNode which looks something like the following:

        <servlet-mapping>
          <servlet-name>redteam</servlet-name>
          <url-pattern>/red/*</url-pattern>
        </servlet-mapping>
    """
        url_pattern_node = xml_parser_utils.GetChild(node, 'url-pattern')
        if url_pattern_node is not None:
            self.web_xml.patterns.append(url_pattern_node.text)
            id_attr = xml_parser_utils.GetAttribute(url_pattern_node, 'id')
            if id_attr:
                self.web_xml.pattern_to_id[url_pattern_node.text] = id_attr
コード例 #6
0
 def ProcessAsyncSessionPersistenceNode(self, node):
     enabled = xml_parser_utils.BooleanValue(
         xml_parser_utils.GetAttribute(node, 'enabled'))
     self.app_engine_web_xml.async_session_persistence = enabled
     queue_name = xml_parser_utils.GetAttribute(node, 'queue-name').strip()
     self.app_engine_web_xml.async_session_persistence_queue_name = queue_name
コード例 #7
0
 def ProcessEnvVariablesNode(self, node):
     for sub_node in xml_parser_utils.GetNodes(node, 'env-var'):
         prop_name = xml_parser_utils.GetAttribute(sub_node, 'name')
         prop_value = xml_parser_utils.GetAttribute(sub_node, 'value')
         self.app_engine_web_xml.env_variables[prop_name] = prop_value
コード例 #8
0
 def ProcessVmSettingsNode(self, node):
     for sub_node in xml_parser_utils.GetNodes(node, 'setting'):
         prop_name = xml_parser_utils.GetAttribute(sub_node, 'name')
         prop_value = xml_parser_utils.GetAttribute(sub_node, 'value')
         self.app_engine_web_xml.vm_settings[prop_name] = prop_value
コード例 #9
0
 def ProcessSystemPropertiesNode(self, node):
     for sub_node in xml_parser_utils.GetNodes(node, 'property'):
         prop_name = xml_parser_utils.GetAttribute(sub_node, 'name')
         prop_value = xml_parser_utils.GetAttribute(sub_node, 'value')
         self.app_engine_web_xml.system_properties[prop_name] = prop_value