subclass ATWorkgroup

9 messages Options
Embed this post
Permalink
cswank () subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
Hello,
I am trying to subclass ATWorkgroup.  When my __init__:

def __init__(self, *args, **kw):
        super(Vendor, self).__init__(*args, **kw)

 gets called I get the following error:

TypeError: super(type, obj): obj must be an instance or subtype of type

When I set a pdb trace to see what obj is, it is an instance 'type', but it has no memory address.  Is there something I'm missing when I am doing this?

Thanks,

Craig

PS.  The only reason I'm doing this is because I want the title field of my content type to be populated with a SelectionWidget.  Perhaps there is some way I can do this without subclassing?
ajung () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
On 16.06.09 22:24, cswank wrote:

> Hello,
> I am trying to subclass ATWorkgroup.  When my __init__:
>
> def __init__(self, *args, **kw):
>         super(Vendor, self).__init__(*args, **kw)
>
>  gets called I get the following error:
>
> TypeError: super(type, obj): obj must be an instance or subtype of type
>  
And where is the class definition? Please provide consistent and half-way
sense-making code snippets.

Andreas

[lists.vcf]

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
cswank () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink

Andreas Jung-5 wrote:
On 16.06.09 22:24, cswank wrote:
> Hello,
> I am trying to subclass ATWorkgroup.  When my __init__:
>
> def __init__(self, *args, **kw):
>         super(Vendor, self).__init__(*args, **kw)
>
>  gets called I get the following error:
>
> TypeError: super(type, obj): obj must be an instance or subtype of type
>  

And where is the class definition? Please provide consistent and half-way
sense-making code snippets.

Andreas


My class definition is as such:

class Vendor(ATWorkgroup):
    """Description of the Example Type"""
    implements(IVendor)

    meta_type = "Vendor"
    schema = VendorSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')
   
    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    vendor_id = atapi.ATFieldProperty('vendorID')

    actions = ATWorkgroup.actions

    schema["title"].required = 0
    schema["title"].widget.visible = {"edit":"hidden", "view":"visible"}
    schema["title"].widget = atapi.SelectionWidget()
    schema["title"].vocbulary_factory = u'.nrel.hydrogen.manufacturers'
    schema["description"].widget.visible = {"edit":"hidden", "view":"hidden"}
    schema["vendorID"].widget.visible = {"edit":"visible", "view":"hidden"}

     def __init__(self, *args, **kw):
        super(Vendor, self).__init__(*args, **kw)

And more detail on what is happening in the __init__ when I set a pdb trace:
ipdb> self
Out[0]: <Vendor at >
ipdb> isinstance(self, Vendor)
Out[0]: False



begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:info@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard


_______________________________________________
Product-Developers mailing list
Product-Developers@lists.plone.org
http://lists.plone.org/mailman/listinfo/product-developers
cswank () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
In reply to this post by ajung
I didn't mean to post code with the title field hidden:

class Vendor(ATWorkgroup):
    """Description of the Example Type"""
    implements(IVendor)

    meta_type = "Vendor"
    schema = VendorSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')
   
    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    vendor_id = atapi.ATFieldProperty('vendorID')

    actions = ATWorkgroup.actions

    schema["title"].required = 0
    schema["title"].widget = atapi.SelectionWidget()
    schema["title"].vocbulary_factory = u'nrel.hydrogen.manufacturers'
    schema["description"].widget.visible = {"edit":"hidden", "view":"hidden"}

    def __init__(self, *args, **kw):
        from ipdb import set_trace; set_trace()
        super(Vendor, self).__init__(*args, **kw)

Andreas Jung-5 wrote:
On 16.06.09 22:24, cswank wrote:
> Hello,
> I am trying to subclass ATWorkgroup.  When my __init__:
>
> def __init__(self, *args, **kw):
>         super(Vendor, self).__init__(*args, **kw)
>
>  gets called I get the following error:
>
> TypeError: super(type, obj): obj must be an instance or subtype of type
>  

And where is the class definition? Please provide consistent and half-way
sense-making code snippets.

Andreas

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:info@zopyx.com
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard


_______________________________________________
Product-Developers mailing list
Product-Developers@lists.plone.org
http://lists.plone.org/mailman/listinfo/product-developers
Maurits van Rees-3 () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
In reply to this post by cswank
cswank, on 2009-06-17:

>> My class definition is as such:
>>
>> class Vendor(ATWorkgroup):
>>     """Description of the Example Type"""
>>     implements(IVendor)
>>
>>     meta_type = "Vendor"
>>     schema = VendorSchema
>>
>>     title = atapi.ATFieldProperty('title')
>>     description = atapi.ATFieldProperty('description')
>>    
>>     # -*- Your ATSchema to Python Property Bridges Here ... -*-
>>     vendor_id = atapi.ATFieldProperty('vendorID')
>>
>>     actions = ATWorkgroup.actions

I do not see why this would be needed.  Inheriting from ATWorkgroup
means you also inherit the actions from ATWorkgroup. :)

>>     schema["title"].required = 0
>>     schema["title"].widget.visible = {"edit":"hidden", "view":"visible"}
>>     schema["title"].widget = atapi.SelectionWidget()
>>     schema["title"].vocbulary_factory = u'.nrel.hydrogen.manufacturers'

vocbulary_factory should be vocabulary_factory

>>     schema["description"].widget.visible = {"edit":"hidden",
>> "view":"hidden"}
>>     schema["vendorID"].widget.visible = {"edit":"visible",
>> "view":"hidden"}

Also, the schema should be edited outside of the class definition.

I cannot imagine that these proposed changes fix your problem, but I
spot no other glaring errors.

>> And more detail on what is happening in the __init__ when I set a pdb
>> trace:
>> ipdb> self
>> Out[0]: <Vendor at >
>> ipdb> isinstance(self, Vendor)
>> Out[0]: False

weird...

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
cswank () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
Sorry, those errors are due to me messing around with a bunch of iterations of the code, and then trying to get the code back to a point that illustrates the the main problem.  You are correct, however, those errors you spotted do not fix my problem.


Maurits van Rees-3 wrote:
cswank, on 2009-06-17:
>> My class definition is as such:
>>
>> class Vendor(ATWorkgroup):
>>     """Description of the Example Type"""
>>     implements(IVendor)
>>
>>     meta_type = "Vendor"
>>     schema = VendorSchema
>>
>>     title = atapi.ATFieldProperty('title')
>>     description = atapi.ATFieldProperty('description')
>>    
>>     # -*- Your ATSchema to Python Property Bridges Here ... -*-
>>     vendor_id = atapi.ATFieldProperty('vendorID')
>>
>>     actions = ATWorkgroup.actions

I do not see why this would be needed.  Inheriting from ATWorkgroup
means you also inherit the actions from ATWorkgroup. :)

>>     schema["title"].required = 0
>>     schema["title"].widget.visible = {"edit":"hidden", "view":"visible"}
>>     schema["title"].widget = atapi.SelectionWidget()
>>     schema["title"].vocbulary_factory = u'.nrel.hydrogen.manufacturers'

vocbulary_factory should be vocabulary_factory

>>     schema["description"].widget.visible = {"edit":"hidden",
>> "view":"hidden"}
>>     schema["vendorID"].widget.visible = {"edit":"visible",
>> "view":"hidden"}

Also, the schema should be edited outside of the class definition.

I cannot imagine that these proposed changes fix your problem, but I
spot no other glaring errors.

>> And more detail on what is happening in the __init__ when I set a pdb
>> trace:
>> ipdb> self
>> Out[0]: <Vendor at >
>> ipdb> isinstance(self, Vendor)
>> Out[0]: False

weird...

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]


_______________________________________________
Product-Developers mailing list
Product-Developers@lists.plone.org
http://lists.plone.org/mailman/listinfo/product-developers
Raphael Ritz () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
In reply to this post by cswank
cswank wrote:
> Hello,
> I am trying to subclass ATWorkgroup.  When my __init__:
>
> def __init__(self, *args, **kw):
>         super(Vendor, self).__init__(*args, **kw)
>
>  gets called I get the following error:
>
> TypeError: super(type, obj): obj must be an instance or subtype of type

Depending on how ATWorkgroup is defined it might not support
calling 'super'. Try calling

    ATWorkgruop.__init__(self,*args,**kw)

(or similar) instead (ATWorkgroup being the class here).
This may well apply to all AT-based types.

I simply don't know whether we moved the entire stack to
using new-style classes by now.

Does that make a difference?

Raphael


>
> When I set a pdb trace to see what obj is, it is an instance 'type', but it
> has no memory address.  Is there something I'm missing when I am doing this?
>
> Thanks,
>
> Craig
>
> PS.  The only reason I'm doing this is because I want the title field of my
> content type to be populated with a SelectionWidget.  Perhaps there is some
> way I can do this without subclassing?


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
cswank () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink
When I try:

ATWorkgroup.__init__(self,*args,**kw)

in my __init__ I get:

TypeError: unbound method __init__() must be called with ATWorkgroup instance as first argument (got Vendor instance instead).  

And when I try not defining an __init__ method then I can initialize my class, but the ATWorkgroup tabs (such as Add Members and Workgroup Roles) do not appear.  So I guess I'm still stuck.

Craig




Raphael Ritz wrote:
cswank wrote:
> Hello,
> I am trying to subclass ATWorkgroup.  When my __init__:
>
> def __init__(self, *args, **kw):
>         super(Vendor, self).__init__(*args, **kw)
>
>  gets called I get the following error:
>
> TypeError: super(type, obj): obj must be an instance or subtype of type

Depending on how ATWorkgroup is defined it might not support
calling 'super'. Try calling

    ATWorkgruop.__init__(self,*args,**kw)

(or similar) instead (ATWorkgroup being the class here).
This may well apply to all AT-based types.

I simply don't know whether we moved the entire stack to
using new-style classes by now.

Does that make a difference?

Raphael


>
> When I set a pdb trace to see what obj is, it is an instance 'type', but it
> has no memory address.  Is there something I'm missing when I am doing this?
>
> Thanks,
>
> Craig
>
> PS.  The only reason I'm doing this is because I want the title field of my
> content type to be populated with a SelectionWidget.  Perhaps there is some
> way I can do this without subclassing?


_______________________________________________
Product-Developers mailing list
Product-Developers@lists.plone.org
http://lists.plone.org/mailman/listinfo/product-developers
ajung () Re: subclass ATWorkgroup
Reply Threaded More More options
Print post
Permalink


On Thu, Jun 18, 2009 at 17:44, cswank <[hidden email]> wrote:

When I try:

ATWorkgroup.__init__(self,*args,**kw)

in my __init__ I get:

TypeError: unbound method __init__() must be called with ATWorkgroup
instance as first argument (got Vendor instance instead).

And when I try not defining an __init__ method then I can initialize my
class, but the ATWorkgroup tabs (such as Add Members and Workgroup Roles) do
not appear.  So I guess I'm still stuck.

No idea what you are trying to do within __init__(). If you need to perform post
create operations, use the at_post_create_script() hook.

-aj

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers