Created
February 21, 2011 09:05
-
-
Save slok/836833 to your computer and use it in GitHub Desktop.
metaproxy script loader snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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