Ejemplo n.º 1
0
 def build_schema(self):
     """Process L{Types} objects and create the schema collection."""
     container = SchemaCollection(self)
     for t in [t for t in self.types if t.local()]:
         for root in t.contents():
             schema = Schema(root, self.url, self.options, container)
             container.add(schema)
     if not len(container):
         root = Element.buildPath(self.root, "types/schema")
         schema = Schema(root, self.url, self.options, container)
         container.add(schema)
     self.schema = container.load(self.options)
     for s in [t.schema() for t in self.types if t.imported()]:
         self.schema.merge(s)
     return self.schema
Ejemplo n.º 2
0
 def build_schema(self):
     """Process L{Types} objects and create the schema collection."""
     loaded_schemata = {}
     container = SchemaCollection(self)
     for t in (t for t in self.types if t.local()):
         for root in t.contents():
             schema = Schema(root, self.url, self.options, loaded_schemata, container)
             container.add(schema)
     if not container:
         root = Element.buildPath(self.root, "types/schema")
         schema = Schema(root, self.url, self.options, loaded_schemata, container)
         container.add(schema)
     self.schema = container.load(self.options, loaded_schemata)
     #TODO: Recheck this XSD schema merging. XSD schema imports are not
     # supposed to be transitive. They only allow the importing schema to
     # reference entities from the imported schema, but do not include them
     # as their own content.
     for s in (t.schema() for t in self.types if t.imported()):
         self.schema.merge(s)
     return self.schema
Ejemplo n.º 3
0
def _patched_instance(self, root, baseurl, options):
    """
    Dynamic implementation of
    delivery_carrier_label_postlogistics/patches/suds_recursion.patch
    (https://fedorahosted.org/suds/attachment/ticket/239/suds_recursion.patch)
    so it's done automatically when the module is loaded.

    Create and return an new schema object using the
    specified I{root} and I{url}.
    @param root: A schema root node.
    @type root: L{sax.element.Element}
    @param baseurl: A base URL.
    @type baseurl: str
    @param options: An options dictionary.
    @type options: L{options.Options}
    @return: The newly created schema object.
    @rtype: L{Schema}
    @note: This is only used by Import children.
    """
    global PROCESSED_IMPORTS_CACHE, PROCESSED_IMPORT_DEPTH, MAX_IMPORT_DEPTH
    if baseurl not in PROCESSED_IMPORTS_CACHE:
        if baseurl in PROCESSED_IMPORT_DEPTH:
            if (PROCESSED_IMPORT_DEPTH[baseurl] < MAX_IMPORT_DEPTH):
                PROCESSED_IMPORT_DEPTH[baseurl] += 1
                _logger.debug('Increasing import count for: %s' % baseurl)
            else:
                _logger.debug(
                    'Maxdepth (%d) reached; Skipping processed import: %s' %
                    (MAX_IMPORT_DEPTH, baseurl))
                return None
        else:
            PROCESSED_IMPORT_DEPTH[baseurl] = 1
            _logger.debug('Importing for the first time: %s' % baseurl)

        PROCESSED_IMPORTS_CACHE[baseurl] = Schema(root, baseurl, options)
        _logger.debug('Successfully cached import: %s' % baseurl)
    else:
        _logger.debug('Retrieving import from cache: %s' % baseurl)
    return PROCESSED_IMPORTS_CACHE[baseurl]