Exemple #1
0
	def _get_tag_obj(self, tag, attrs):
		attrdict = {}
		def fixatts(t):
			attrdict[t[0]] = t[1]
		map(fixatts, attrs)
		cl = getattr(self.doc.dtd, identifier(tag))
		cl.__bases__ = (XHTMLElement,) # XXX quck hack
		obj = apply(cl, (), attrdict)
		return obj
Exemple #2
0
	def _get_class(self, name):
		klass = None
		for mod in self.modules:
			try:
				klass = getattr(mod, identifier(name)) # name dtd compiler translated to
			except AttributeError:
				continue
			if klass:
				return klass
		raise AttributeError
Exemple #3
0
	def new_element_type(self, elem_name, elem_cont):
		"Receives the declaration of an element type."
		try:
			element = self.elements[elem_name]
		except KeyError:
			parents = [ElementNode]
			mixinname = "%sMixin" % ( elem_name )
			if self.mixins and hasattr(self.mixins, mixinname):
				parents.insert(0, getattr(self.mixins, mixinname))
			# class name is capitalized to avoid clashes with Python key words.
			ch = self.generator.add_class(identifier(elem_name), tuple(parents))
			ch.add_attribute("_name", elem_name)
			ch.add_attribute("CONTENTMODEL", _ContentModelGenerator(elem_cont))
			self.elements[elem_name] = ch
Exemple #4
0
	def _element_getter(dtdmod, nodename):
		return getattr(dtdmod, identifier(nodename))