Here some ideas:
-To calling a superclass method i think the better way is use the built
in super(...), i think in your code maybe something like:
def __init__(self, labeltext):
super(ControlContribution,self).__init__(self,labeltext)
- Sometimes the superclass (at the top of the hierachy of inheritance)
need to ineritance from the class 'object' (or 'Object', i don't
remember). An easy example to understand this is:
class MySuperClass(object):
...
class MyMiddleClass(MySuperClass):
...
class MyDefinitiveClass(MyMiddleClass):
....
So in your code the COntrolContribution must inheritance from Object, i
don't really know how to do this from a Java class, may be:
class ControlContribution(object):
...
class MyControlContribution(ControlContribution)
..
(ok i know that before is very strange)or maybe something like:
class MyControlContribution(object, ControlContribution):
...
-But now i doubt if jython is able to have multiple inheritance....mmm i
think the problem may be too the ControlContribution is imported from
Java so it hasn't an __init__ method really; but i'm not really sure
about it.
Try these posibilities, if haven't better ones.
David Huebel escribió:
> Hi all,
>
> I have run into difficulty calling a superclass constructor again.
> This time I upgraded to jython 2.2rc2 and created a minimal failure
> case. This should either make it obvious what I'm doing wrong or make
> it easy for anyone who has Eclipse to reproduce the problem.
>
> To recap: When my constructor attempts to call the superclass
> constructor, I get an AttributeError saying that the superclass has no
> attribute '__init__'.
>
> Here is a session where I declare a minimal subclass of the abstract
> class org.eclipse.jface.action.ControlContribution, trigger the error,
> and verify that ControlContribution has a protected constructor that
> takes a single String argument. ECLIPSE_CP is a classpath containing
> all the jars in my eclipse/plugins/ directory. (More comments below
> the session.)
>
> -------------------------
>
> dhuebel@...:~$ rlwrap /opt/jython2.2rc2/jython
> -Dpython.path=$PYTHONPATH:$ECLIPSE_CP
> Jython 2.2rc2 on java1.6.0
> Type "copyright", "credits" or "license" for more information.
>
> from org.eclipse.jface.action import ControlContribution
>
> class ComboContributionItem2(ControlContribution):
> def __init__(self, labelText):
> ControlContribution.__init__(self, labelText)
>
> def createControl(self, *args):
> return None
>
>
>>>>>>> ... ... ... >>> >>> ...
>>>>>>>
> ...
>
>>>> con = ComboContributionItem2('hi')
>>>>
> Traceback (innermost last):
> File "<console>", line 1, in ?
> File "<console>", line 3, in __init__
> AttributeError: class 'org.eclipse.jface.action.ControlContribution'
> has no attribute '__init__'
>
>>>> len(ControlContribution.getDeclaredConstructors())
>>>>
> 1
>
>>>> ControlContribution.getDeclaredConstructors()[0]
>>>>
> protected org.eclipse.jface.action.ControlContribution(java.lang.String)
>
>
> -----------------------
>
> Possibly relevant: I can directly invoke the protected constructor of
> the abstract class java.lang.Number, but I cannot directly invoke the
> constructor of ControlContribution:
>
>
>>>> Number.__init__(None)
>>>>
> Traceback (innermost last):
> File "<console>", line 1, in ?
> TypeError: invalid self argument to constructor
>
>>>> ControlContribution.__init__(None, 'hi')
>>>>
> Traceback (innermost last):
> File "<console>", line 1, in ?
> AttributeError: class 'org.eclipse.jface.action.ControlContribution'
> has no attribute '__init__'
>
> Please help me out if there's an obvious error in my code. Otherwise,
> are there any other debugging steps I should take?
>
> Thanks,
> David
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
|