[Zope-CMF] error installing CMFCalendar in CMF-1.1beta
Tres Seaver
tseaver@palladion.com
Sun, 03 Jun 2001 23:21:05 -0400
This is a multi-part message in MIME format.
--------------010200080605050805070601
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
marc lindahl wrote:
> 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
OK, I'll attach the whole file, instead of relying on my mailer
not to munge stuff.
Tres.
--
===============================================================
Tres Seaver tseaver@digicool.com
Digital Creations "Zope Dealers" http://www.zope.org
--------------010200080605050805070601
Content-Type: text/plain;
name="dump_md_tool.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="dump_md_tool.py"
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' )
--------------010200080605050805070601--