Esempio n. 1
0
def construct_class(node,parent):
    """Create a node from the xml tag."""
    
    #for all of the available tag_names

    if hasattr(wildfire.tags[node.tag],'tag'):
        node = extend(node,wildfire.tags[node.tag].tag)
    
    new_node = wildfire.tags[node.tag](parent,node)

    return new_node
Esempio n. 2
0
    def _construct(self):

        parent_tag = None

        # if it's extending something other than view
        if self.tag.get("extends"):
            # get what it's looking for
            # search_tag = self.tag.get('extends')

            #             for tag in wildfire.tags:
            #                 #find a match
            #                 if search_tag == tag.__tag__:
            #                     parent_tag = tag

            #                     self.tag = extend(self.tag,parent_tag.tag,attributes=False)
            #                     self.tag.attrib.pop('extends')

            parent_tag = wildfire.tags[self.tag.get("extends")]

            self.tag = extend(self.tag, wildfire.tags[self.tag.get("extends")].tag, attributes=False)

        else:
            # if we're just extending node
            parent_tag = node

        if parent_tag is None:
            raise Exception("Could not find super tag %s" % search_tag)

        # create a copy of the class
        # new_class = new.classobj(str(self.tag.get('name')),parent_tag.__bases__, parent_tag.__dict__.copy())

        if self.tag.get("extends") is None:
            parent_tag = node
        else:
            parent_tag = wildfire.tags[self.tag.get("extends")]

        new_class = type(self.tag.get("name"), (parent_tag, object), {})

        # assign it's new __tag__
        new_class.__tag__ = self.tag.get("name")

        # attach the DOM tag
        new_class.tag = self.tag

        # replace it if necessary
        # for i,tag in enumerate(wildfire.tags):
        #    if tag.__tag__ == new_class.__tag__:
        #        wildfire.tags[i] = new_class
        #        return

        wildfire.tags[self.tag.get("name")] = new_class