AllowedTypesByIface breaks
"Martin Aspeli" <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.archetypes.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
While trying out ATVocabularyManager on Plone 2.1, Python 2.3.5, Zope 2.8,
I found that I got errors when trying to rename a vocabulary. The
offending code is in Archetypes' AllowedTypesByIface:
def _verifyObjectPaste(self, object, validate_src=1):
"""Overrides PortalFolder._verifyObjectPaste."""
# XXX: What we do here is trick
# PortalFolder._verifyObjectPaste in its check for
# allowed content types. We make our typeinfo temporarily
# unavailable.
pt = getToolByName(self, 'portal_types')
tmp_name = '%s_TMP' % self.portal_type
ti = pt.getTypeInfo(self.portal_type)
pt.manage_delObjects([self.portal_type])
value = PortalFolder._verifyObjectPaste(self, object, validate_src)
pt._setObject(self.portal_type, ti)
return value
Now, first of all, that code is rather insane. I think the idea (making
allowable types work on interface instead of explicit list) is quite nice,
but that particular function seems a little extreme. ;-) Anyway ...
This line fails:
value = PortalFolder._verifyObjectPaste(self, object, validate_src)
With an error that the unbound method _verifyObjectPaste must be called
with PortalFolder as its first argument. That seems a bit odd to me, since
the tool is defined as
class VocabularyLibrary(UniqueObject, AllowedTypesByIfaceMixin,
OrderedBaseFolder):
And OrderedBaseFolder inherits from BaseFolder which inherits from
PortalFolder. Moving the OrderedBaseFolder derivation first in the list
fixes this problem, but breaks the AllowedTypesByIface. I managed to fix
this by adding a custom _verifyObjectPaste() to ATVM's VocabularyLibrary
tool that does this:
def _verifyObjectPaste(self, object, validate_src=1):
# XXX: Archetyps' AllowedTypesByIface is broken, this override is
# necessary to avoid an error
pt = getToolByName(self, 'portal_types')
ti = pt.getTypeInfo(self.portal_type)
pt.manage_delObjects([self.portal_type])
# Changed this from using PortalFolder to using OrderedBaseFolder,
# without this change, we'll get an error
value = OrderedBaseFolder._verifyObjectPaste(self, object,
validate_src)
pt._setObject(self.portal_type, ti)
return value
I think AllowedTypesByIface should be fixed, but I don't know how best to
do it and work around any more crazy inheritance rules.
Martin
--
(muted)
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642