## Script (Python) "wnhistory" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # Example code: import zLOG false = 0 true = 1 # Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote, url_quote request = container.REQUEST RESPONSE = request.RESPONSE urlpath = string.split(request.URLPATH0, '/') objectpath = request.PARENTS objectpath.reverse() objectpath.append(request.PUBLISHED) #zLOG.LOG("nym", zLOG.INFO, "objectpath %s" % (objectpath)) objectpath = objectpath[-len(urlpath):] # Trimmed head of objectpath so that objectpath and urlpath align # exactly. This is necessary because the objectpath can contain # objects with no corresponding URL element, such as occurs with # VirtualHostMonster. if (len(urlpath) != len(objectpath)): raise Exception(('array lengths do not match: objectpath: %d urlpath: %d, objectpath = %s, urlpath: %s' % (len(objectpath), len(urlpath), objectpath, urlpath))) wnobject = context.getWN() word = context.getWord() # skip ahead to the wordnet object foundwn = false for i in range(0,len(objectpath)-1): if (objectpath[i] is wnobject): foundwn = true continue if (foundwn == false): continue if (urlpath[i+1].isdigit() and not urlpath[i].isdigit()): continue if (objectpath[i+1] is word): tail = 'wnchoosemeaning?word=%s' % objectpath[i].getForms()[0] elif (request.PUBLISHED.id == 'wnhistory'): tail = 'wnhistory' else: tail = 'wnbrowse' if (urlpath[i].isdigit() and not urlpath[i-1].isdigit()): r = urlpath[i-1] if (r.endswith('s')): r = r[0:-1] print html_quote('-(%s)->' % r) print ('%s' % (request.BASE1, string.join(map(url_quote, urlpath[0:i+1]),'/'), tail, html_quote(objectpath[i].getForms()[0]) ) ) return printed