Skip to content

Instantly share code, notes, and snippets.

@slok
Created February 21, 2011 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slok/836833 to your computer and use it in GitHub Desktop.
Save slok/836833 to your computer and use it in GitHub Desktop.
metaproxy script loader snippet
#with resp.body_stream() as body:
body = resp.body_string()
#-----------------------------------------------------------------------
#get path and split in "/" parts
actualPath = request.get_full_path()
parts = []
for part in actualPath.split('/'):
parts.append(part)
#create the import string. Ex: scripts.dipina.ModifyBody
importString = "scripts."
importString += parts[2] #The 3rd position is where the id is
importString += ".ModifyBody"
#import in a local var
mBImport = __import__(importString, fromlist=['*'])
"""
if "dipina" in actualPath:
from scripts.dipina.ModifyBody import *
print "importado!!!!!"
elif "dbujan" in actualPath:
from scripts.dbujan.ModifyBody import *
#...
"""
print importString
print mBImport
mb = mBImport.ModifyBody()
body = mb.body_modification_logic(body)
#-----------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment