[Zope-CMF] Is there a way to change the meta-type of a number of object types

Norman Khine khine@btinternet.com
Tue, 31 Jul 2001 23:26:44 +0100


Hello Tres,
Sorry to bother you with trivia stuff, but I am having difficulties in
running the external method and get the following error:

Error Type: NameError
Error Value: name 'self' is not defined

Traceback (innermost last):
  File /usr/home/dsuk5/zope/2.4.0/lib/python/ZPublisher/Publish.py, line
223, in publish_module
  File /usr/home/dsuk5/zope/2.4.0/lib/python/ZPublisher/Publish.py, line
187, in publish
  File /usr/home/dsuk5/zope/2.4.0/lib/python/Zope/__init__.py, line 226, in
zpublisher_exception_hook
  File /usr/home/dsuk5/zope/2.4.0/lib/python/ZPublisher/Publish.py, line
171, in publish
  File /usr/home/dsuk5/zope/2.4.0/lib/python/ZPublisher/mapply.py, line 160,
in mapply
    (Object: manage_addExternalMethod)
  File /usr/home/dsuk5/zope/2.4.0/lib/python/ZPublisher/Publish.py, line
112, in call_object
    (Object: manage_addExternalMethod)
  File
/usr/home/dsuk5/zope/2.4.0/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 131, in manage_addExternalMethod
  File
/usr/home/dsuk5/zope/2.4.0/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 179, in __init__
    (Object: update)
  File
/usr/home/dsuk5/zope/2.4.0/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 202, in manage_edit
    (Object: update)
  File
/usr/home/dsuk5/zope/2.4.0/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 209, in getFunction
    (Object: update)
  File /usr/home/dsuk5/zope/2.4.0/lib/python/App/Extensions.py, line 217, in
getObject
    (Info: ('/usr/home/dsuk5/zope/2.4.0/Extensions/change_type.py',
'change_type'))
  File /usr/home/dsuk5/zope/2.4.0/Extensions/change_type.py, line 2, in ?
NameError: (see above)

Any help would be much welcomed.

Regrds

Norman

-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Tres Seaver
Sent: 31 July 2001 13:22
To: Norman Khine
Cc: Zope-CMF
Subject: Re: [Zope-CMF] Is there a way to change the meta-type of a
number of object types


Norman Khine wrote:

> Using the external method as described, does it mean, I can modify other
> attributes, just by including
>
>  doc = brain.getObject()
>        doc.portal_type = 'Card'
> ---->  doc.review_state = 'published'
>        updated.append( doc )
>
> if I want to make all these documents published, for example?


Yes, that is possible.  You might rather call the appropriate
workflow methods, however, as setting the attribute directly
breaks encapsulation;  for a one-time hack, it won't be too awful.


> Also, shouldn't portal_type be meta_type, as I am changing the meta_type
> from Document to Card?

If I understood your original question, you have created a new

type object, "Card", based against the CMFDefault.Document Python
class.  In this case, the 'meta_type' of the instances will still
be 'Document', but the 'portal_type' (the ID of the type objects)
will be 'Card'.  I can't think of any time when I would want to
set the 'meta_type' on an instance to be different from its class.

Tres.
--
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com


_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests