metaclass error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • asteele@berkeley.edu

    #1

    metaclass error

    dear readers,

    i have a very simple package organized as follows:

    !-----------------------------------------!
    bgp/
    __init__.py
    managers/
    __init__.py
    ManagerInterfac e.py
    TestManager.py
    !-----------------------------------------!

    and here's ManagerInterfac e.py and TestManager.py:

    !-----------------------------------------!
    # ManagerInterfac e.py
    class ManagerInterfac e(object):
    def __init__(self): pass
    def process(self, recset, operation):
    print 'In ManagerInterfac e.process()...'

    # TestManager.py
    import ManagerInterfac e
    class TestManager(Man agerInterface):
    def process(self, recset, operation):
    print 'In TestManager.pro cess()...'
    super(TestManag er,self).proces s(recset,operat ion)
    !-------------------------------------------!

    when i try to import the TestManager module via the interpreter, i get
    the following error:

    !-------------------------------------------!
    $ python
    Python 2.4.1c1 (#1, Mar 14 2005, 10:28:18)
    [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-49)] on linux2[color=blue][color=green][color=darkred]
    >>> import bgp.managers.Te stManager[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "bgp/managers/TestManager.py" , line 2, in ?
    class TestManager(Man agerInterface):
    TypeError: Error when calling the metaclass bases
    module.__init__ () takes at most 2 arguments (3 given)
    !-------------------------------------------!

    any thoughts? i think that when python executes the TestManager class
    statement, it collects the base class (ManagerInterfa ce) into a tuple
    and then executes the class body in a dictionary... is this where the
    error is happening?

    thanks!
    aaron

  • F. Petitjean

    #2
    Re: metaclass error

    Le 17 Mar 2005 12:27:07 -0800, asteele@berkele y.edu a écrit :[color=blue]
    > dear readers,
    >
    > i have a very simple package organized as follows:
    >
    > !-----------------------------------------!
    > bgp/
    > __init__.py
    > managers/
    > __init__.py
    > ManagerInterfac e.py
    > TestManager.py
    > !-----------------------------------------!
    >
    > and here's ManagerInterfac e.py and TestManager.py:
    >
    > !-----------------------------------------!
    > # ManagerInterfac e.py
    > class ManagerInterfac e(object):
    > def __init__(self): pass
    > def process(self, recset, operation):
    > print 'In ManagerInterfac e.process()...'
    >
    > # TestManager.py
    > import ManagerInterfac e[/color]
    # ManagerInterfac e is a module not a class !
    # try
    from ManagerInterfac e import ManagerInterfac e[color=blue]
    > class TestManager(Man agerInterface):[/color]
    # you can also define __init__ method with a super call[color=blue]
    > def process(self, recset, operation):
    > print 'In TestManager.pro cess()...'
    > super(TestManag er,self).proces s(recset,operat ion)
    > !-------------------------------------------!
    >
    >
    > thanks!
    > aaron
    >[/color]

    Comment

    • asteele@berkeley.edu

      #3
      Re: metaclass error

      doh, that was the problem. :}

      thanks for the help!
      aaron

      Comment

      • Michele Simionato

        #4
        Re: metaclass error

        F. Petitijean:[color=blue]
        > ManagerInterfac e is a module not a class ![/color]

        Yes, but the error message could be improved (at least for the sake of
        people
        not knowing the internal working of Python). Do you care to fill a bug
        report?

        Michele Simionato

        Comment

        Working...