Ejemplo n.º 1
0
 def resume(self, content):
     #
     # Resume processing a list content.  To do this, we
     # really need to simply push the 'list' content
     # back onto the resolver stack.
     #
     self.resolver.push(Frame(content.type))
Ejemplo n.º 2
0
 def start(self, content):
     #
     # Start marshalling the 'content' by ensuring that both the 'content'
     # _and_ the resolver are primed with the XSD type information. The
     # 'content' value is both translated and sorted based on the XSD type.
     # Only values that are objects have their attributes sorted.
     #
     log.debug('starting content:\n%s', content)
     if content.type is None:
         name = content.tag
         if name.startswith('_'):
             name = '@' + name[1:]
         content.type = self.resolver.find(name, content.value)
         if content.type is None:
             raise TypeNotFound(content.tag)
     else:
         known = None
         if isinstance(content.value, Object):
             known = self.resolver.known(content.value)
             if known is None:
                 log.debug('object %s has no type information',
                           content.value)
                 known = content.type
         frame = Frame(content.type, resolved=known)
         self.resolver.push(frame)
     frame = self.resolver.top()
     content.real = frame.resolved
     content.ancestry = frame.ancestry
     self.translate(content)
     self.sort(content)
     if self.skip(content):
         log.debug('skipping (optional) content:\n%s', content)
         self.resolver.pop()
         return False
     return True
Ejemplo n.º 3
0
 def resume(self, content):
     """
     Appending this content has resumed.
     @param content: The content for which proccessing has been resumed.
     @type content: L{Object}
     """
     frame = Frame(content.type)
     self.resolver.push(frame)
Ejemplo n.º 4
0
    def resume(self, content):
        """
        Resume processing list content.

        To do this, we really need to simply push the 'list' content back onto
        the resolver stack.

        """
        self.resolver.push(Frame(content.type))
Ejemplo n.º 5
0
 def start(self, content):
     #
     # Resolve to the schema type; build an object and setup metadata.
     #
     if content.type is None:
         found = self.resolver.find(content.node)
         if found is None:
             log.error(self.resolver.schema)
             raise TypeNotFound(content.node.qname())
         content.type = found
     else:
         known = self.resolver.known(content.node)
         frame = Frame(content.type, resolved=known)
         self.resolver.push(frame)
     real = self.resolver.top().resolved
     content.real = real
     cls_name = real.name
     if cls_name is None:
         cls_name = content.node.name
     content.data = Factory.object(cls_name)
     md = content.data.__metadata__
     md.sxtype = real
Ejemplo n.º 6
0
 def start(self, content):
     """ 
     Resolve to the schema type; build an object and setup metadata.
     @param content: The current content being unmarshalled.
     @type content: L{Content}
     @return: A subclass of Object.
     @rtype: L{Object}
     """
     if content.type is None:
         found = self.resolver.find(content.node)
         if found is None:
             log.error(self.resolver.schema)
             raise TypeNotFound(content.node.qname())
         content.type = found
     else:
         frame = Frame(content.type)
         self.resolver.push(frame)
     cls_name = content.type.name
     if cls_name is None:
         cls_name = content.node.name
     content.data = Factory.object(cls_name)
     md = content.data.__metadata__
     md.sxtype = content.type
Ejemplo n.º 7
0
 def start(self, content):
     """
     Processing of I{content} has started, find and set the content's
     schema type using the resolver.
     @param content: The content for which proccessing has stated.
     @type content: L{Object}
     @return: True to continue appending
     @rtype: boolean
     @note: This will I{push} the type in the resolver.
     """
     log.debug('starting content:\n%s', content)
     if content.type is None:
         name = content.tag
         if name.startswith('_'):
             name = '@'+name[1:]
         content.type = self.resolver.find(name, content.value)
         if content.type is None:
             raise TypeNotFound(content.tag)
     else:
         known = None
         if isinstance(content.value, Object):
             known = self.resolver.known(content.value)
             if known is None:
                 log.debug('object has no type information', content.value)
                 known = content.type
             self.sort(content.value, known)
         frame = Frame(content.type, resolved=known)
         self.resolver.push(frame)
     resolved = self.resolver.top().resolved
     content.value = self.translated(content.value, resolved)
     if self.skip(content):
         log.debug('skipping (optional) content:\n%s', content)
         self.resolver.pop()
         return False
     else:
         return True