Perspective URL Dictionary Parameter

I appreciate the clarifications!

I ended up going the route of encoding the URLs in a way that i can decode back into a dictionary for this use case.

For anyone that wants the scripts here they are

# This takes a dictionary of parameters and converts it into a URL parameter string
def dictionaryToURLParameter(params):
	import urllib
	paramList = []
	for key, value in params.items():
		 try: key = urllib.quote(key)
		 except: key = key
		 try: value = urllib.quote(value)
		 except: value = value
		 paramList.append("%s=%s" % (key, value))
	
    # Replace any slashes with pipes so that the perspective URL parser doesnt fail to understand the text
	return "&".join(paramList).replace('/', '|')

# This takes a URL parameter string and converts it into a dictionary of parameters
def URLStringToDictionary(paramString):
	import urllib
    # Replace any pipes with slashes so that the perspective URL parser doesnt fail to understand the text
	paramString = urllib.unquote(paramString.replace('|', '/'))
	params = {}
	for pair in paramString.split('&'):
		pair = pair.split('=')
		params[pair[0]] = pair[1]
	return params
2 Likes