i have a ZClass with a property which is renderd as structured text. 
Because i designed this ZClass before there was a standard for including 
images, i made my own extension of structured text formating.
Short: I used __imageobject__ as markup for the image.

Now i want to update all my zclass instances to the new syntax (while 
upgrading to Zope 2.5.1).

I have a Python Script listKBE, which call an External Method updateKBE. 
If i use it with a path with only a few ZClass instances (about 10) it 
works (slowly). If i use it with a path with about 550 instances it 
crashes or is extreme slow.
Anyone to suggest a faster method?

Thank you,

## Script (Python) "listKBE"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath

results=context.Catalog(meta_type='IPRO Knowledge Base 
for result in results:
   obj = result.getObject()
   print obj.id
   #print obj.propertyItems()
   #for id,val in obj.propertyItems():
   #  print id
   issue = obj.Issue
   newissue = context.updateKBE(issue)
return printed

-------------------updateKBE points to kbeimage_search_replace --------
import string
import re

def punc_func(exclude):
     punc = r''
     for char in string.punctuation:
         if char not in exclude:
             punc = punc + r'\%s' % char
     return punc

digits      = string.digits
letters     = string.letters
literal_punc = punc_func("'")
dbl_quoted_punc = punc_func("\"")
strongem_punc = punc_func('*')
under_punc = punc_func('_<>')
phrase_delimiters = r'\s\.\,\?\/\!\&\(\)'

def kbeimage_search_replace(text):

     expr = re.compile(r'__([%s%s%s\s]+?)__' % (letters, digits, 
     if r:
         #print r
         start, end = r.span(1)
         newtext=text[:start-2]+newtext+text[start:end]+' '+text[end+2:]
         #print start,end
         #print newtext
         return kbeimage_search_replace(newtext)
         return text

Jochen Knuth          WebMaster http://www.ipro.de
IPRO GmbH             Phone ++49-7152-93330
Steinbeisstr. 6       Fax ++49-7152-933340
71229 Leonberg        EMail: [EMAIL PROTECTED]

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to