Patrick Decat wrote:
Traceback (innermost last):
 Module ZPublisher.Publish, line 101, in publish
 Module ZPublisher.mapply, line 88, in mapply
 Module ZPublisher.Publish, line 39, in call_object
 Module App.Management, line 85, in manage_workspace
The problem, apparently, raises it's head in the 3rd line of the traceback. The code there reads:

def call_object(object, args, request):
   result=apply(object,args) # Type s<cr> to step into published object.
   return result

So, I'm not sending the correct arguments to Zope. This is my first External Script in years (and I'd only written a couple before). So, please help me with this. The script is below in its (short) entirety. It works just fine from the command prompt. The idea is explained in the comments. Please help me understand how to pass it arguments.

This function is to be used as a wrapper before passing to VirtualHostMonster so that I can convert URLs such as this:
I choose to use the former for purposes of getting my pages ranked by Google (since they dislike deep directory structures), but prefer the d
eep dir structure for my use in my Zope instance.

import re
from urlparse import urlparse

def URL_Rewrite(old_url):
item6 = ''
item4 = ''
testPound = re.compile('[a-z_A-Z0-9:\/\.]*[#][a-zA-Z0-9:\/\.]*')
testQuestion = re.compile('[a-z_A-Z0-9:\/\.]*[\?][a-zA-Z0-9:\/\.]*')
testEnding = re.compile('[a-zA-Z_0-9:\/\.#\?]*[p][t]')
if re.match(testPound,old_url):
 item6 = '#'
elif re.match(testQuestion,old_url):
 item6 = '?'
if re.match(testEnding,old_url):
 item4 = '.pt'
parts = urlparse(old_url)
item0 = parts[0]
# The next rule is required because urlparse() deletes the '://'
item0 = item0 + '://'
item1 = parts[1]
item2 = '/x/c/s/j/en-us'
subPartsOf2 = re.split('.pt',parts[2])
item3 = re.sub('\.','/',subPartsOf2[0])
# The other sub-part is an empty string
# The next rule is required because for some reason a ';' gets added by urlparse()
item3 = re.sub(';','',item3)
item5 = parts[3]
item7 = parts[4]
item8 = parts[5]
new_url = item0 + item1 + item2 + item3 + item4 + item5 + item6 + item7 + item8
return new_url

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to