[Zope-CMF] error installing CMFCalendar in CMF-1.1beta

marc lindahl marc@bowery.com
Sun, 03 Jun 2001 23:06:37 -0400


Hi Tres,
Thanks for the suggestion...
I think I'm missing something... I put the snippet below into a file called
hoover_metadata.py in Extensions, and then added an External Method in the
root of my portal, and got an error:

Site Error

  An error was encountered while publishing this resource.

  SyntaxError

  Sorry, a site error occurred.

  Traceback (innermost last):
    File /usr/local/zope/Zope-2.3.1/lib/python/ZPublisher/Publish.py, line
223, in publish_module
    File /usr/local/zope/Zope-2.3.1/lib/python/ZPublisher/Publish.py, line
187, in publish
    File /usr/local/zope/Zope-2.3.1/lib/python/Zope/__init__.py, line 221,
in zpublisher_exception_hook
    File /usr/local/zope/Zope-2.3.1/lib/python/ZPublisher/Publish.py, line
171, in publish
    File /usr/local/zope/Zope-2.3.1/lib/python/ZPublisher/mapply.py, line
160, in mapply
      (Object: manage_addExternalMethod)
    File /usr/local/zope/Zope-2.3.1/lib/python/ZPublisher/Publish.py, line
112, in call_object
      (Object: manage_addExternalMethod)
    File 
/usr/local/zope/Zope-2.3.1/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 131, in manage_addExternalMethod
    File 
/usr/local/zope/Zope-2.3.1/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 179, in __init__
      (Object: dumpMetadataTool)
    File 
/usr/local/zope/Zope-2.3.1/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 202, in manage_edit
      (Object: dumpMetadataTool)
    File 
/usr/local/zope/Zope-2.3.1/lib/python/Products/ExternalMethod/ExternalMethod
.py, line 209, in getFunction
      (Object: dumpMetadataTool)
    File /usr/local/zope/Zope-2.3.1/lib/python/App/Extensions.py, line 217,
in getObject
      (Info: ('/usr/local/zope/Zope-2.3.1/Extensions/hoover_metadata.py',
'hoover_metadata'))
  SyntaxError: invalid token



> From: Tres Seaver <tseaver@palladion.com>
> Date: Sun, 03 Jun 2001 20:29:39 -0400
> To: marc lindahl <marc@bowery.com>
> Cc: Joachim Schmitz <js@aixtraware.de>, zope-cmf <zope-cmf@zope.org>
> Subject: Re: [Zope-CMF] error installing CMFCalendar in CMF-1.1beta
> 
> marc lindahl wrote:
> 
>> No prob...
>> I'm boned, because I had a pile of stuff in the portal_metadata tool, and
>> the updated version is incompatible (I think, due to inheriting Persistent),
>> and there's no current way to import/export just the data from the tool,
>> independant of the internal structure...  AFAIK!
> 
> 
> Marc,
> 
> We could probably work out a means of dumping the data.  How about an
> ExternalMethod which creates a chunk of Python to replicate it?  Something
> like:
> 
> #--------------------- snip here --------------------------------
> import string
> 
> def dumpMetadataTool( self ):
> """
> Extract the contents of the 'portal_metadata' tool as a chunk
> of Python for repopulation.
> """
> tool = self.portal_metadata
> lines = []
> add = lines.append
> add( '## Script (Python) "metadata_load"' )
> add( '##title=Load Metadata Tool' )
> add( '##parameters=' )
> add( 'tool = context.portal_metadata' )
> 
> for element, spec in tool.listElementSpecs():
> 
> for content_type, policy in spec.listPolicies():
> 
> if content_type is not None:
> 
> add( 'try: tool.removeElementPolicy( "%s", "%s" )'
> % ( element, content_type ) )
> add( 'except: pass' )
> 
> spec_args = ( 'tool.addElementPolicy( "%s", "%s",'
> % ( element, content_type ) )
> else:
> spec_args = ( 'tool.updateElementPolicy( "%s",
> "<default>",'
> % element )
> 
> if policy.isMultiValued():
> policy_args = ( ' %d, %d, %s, %d, %s )'
> % ( policy.isRequired()
> , policy.supplyDefault()
> , policy.defaultValue()
> , policy.enforceVocabulary()
> , policy.allowedVocabulary()
> )
> )
> else:
> policy_args = ( ' %d, %d, "%s", %d, %s )'
> % ( policy.isRequired()
> , policy.supplyDefault()
> , policy.defaultValue()
> , policy.enforceVocabulary()
> , policy.allowedVocabulary()
> )
> )
> 
> add( spec_args + policy_args )
> 
> return string.join( lines, '\n' )
> #--------------------- snip here --------------------------------
> 
> I've just run this, and it seems to work for me.
> 
> Tres
> -- 
> ===============================================================
> Tres Seaver                                tseaver@digicool.com
> Digital Creations     "Zope Dealers"       http://www.zope.org
> 
> 
> _______________________________________________
> 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