* add a hook for check() function
* remove the stupid code that tried to add XmlFile as a base class
This commit is contained in:
+5
-9
@@ -198,12 +198,6 @@ class autoxml(oo.autosuper):
|
|||||||
"""entry point for metaclass code"""
|
"""entry point for metaclass code"""
|
||||||
#print 'generating class', name
|
#print 'generating class', name
|
||||||
|
|
||||||
# add XmlFile as one of the superclasses of cls
|
|
||||||
#bases = list(bases)
|
|
||||||
#if not XmlFile in bases:
|
|
||||||
# bases.append(XmlFile)
|
|
||||||
bases = (XmlFile)
|
|
||||||
|
|
||||||
# standard initialization
|
# standard initialization
|
||||||
super(autoxml, cls).__init__(name, bases, dict)
|
super(autoxml, cls).__init__(name, bases, dict)
|
||||||
|
|
||||||
@@ -243,7 +237,7 @@ class autoxml(oo.autosuper):
|
|||||||
if not tag:
|
if not tag:
|
||||||
tag = cls.tag
|
tag = cls.tag
|
||||||
#self.__super.__init__(tag = tag) #FIXME: doesn't work, why? :(
|
#self.__super.__init__(tag = tag) #FIXME: doesn't work, why? :(
|
||||||
super(cls, self).__init__(tag = tag)
|
super(cls, self).__init__(tag = tag) # tag for XmlFile support
|
||||||
for init in self.__class__.initializers:
|
for init in self.__class__.initializers:
|
||||||
init(self)
|
init(self)
|
||||||
# init hook
|
# init hook
|
||||||
@@ -269,6 +263,8 @@ class autoxml(oo.autosuper):
|
|||||||
errs = []
|
errs = []
|
||||||
for checker in self.__class__.checkers:
|
for checker in self.__class__.checkers:
|
||||||
errs.extend(checker(self, where))
|
errs.extend(checker(self, where))
|
||||||
|
if hasattr(self, 'check_hook'):
|
||||||
|
errs.extend(self.check_hook(where))
|
||||||
return errs
|
return errs
|
||||||
cls.check = check
|
cls.check = check
|
||||||
|
|
||||||
@@ -287,8 +283,8 @@ class autoxml(oo.autosuper):
|
|||||||
for x in errs:
|
for x in errs:
|
||||||
ctx.ui.warning(x)
|
ctx.ui.warning(x)
|
||||||
cls.print_text = print_text
|
cls.print_text = print_text
|
||||||
#if not dict.has_key('__str__'):
|
if not dict.has_key('__str__'):
|
||||||
# cls.__str__ = str
|
cls.__str__ = print_text
|
||||||
|
|
||||||
def gen_attr_member(cls, attr):
|
def gen_attr_member(cls, attr):
|
||||||
"""generate readers and writers for an attribute member"""
|
"""generate readers and writers for an attribute member"""
|
||||||
|
|||||||
@@ -45,10 +45,6 @@ class XmlFileTestCase(unittest.TestCase):
|
|||||||
t_OtherInfo = [ OtherInfo, xmlfile.optional ]
|
t_OtherInfo = [ OtherInfo, xmlfile.optional ]
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
print A.__class__
|
|
||||||
print super(A)
|
|
||||||
print A.__dict__
|
|
||||||
print OtherInfo.__dict__
|
|
||||||
self.assertEqual(a.href, None)
|
self.assertEqual(a.href, None)
|
||||||
dom = mdom.parse('tests/a.xml')
|
dom = mdom.parse('tests/a.xml')
|
||||||
node = getNode(dom, 'A')
|
node = getNode(dom, 'A')
|
||||||
|
|||||||
Reference in New Issue
Block a user