Created
September 23, 2011 19:24
-
-
Save natevw/1238217 to your computer and use it in GitHub Desktop.
based on https://github.com/natevw/ShutterStem/blob/2a1ad2db119a19e2cd192d52056ac682a50b27f6/_attachments/scripts/couch.py in response to https://gist.github.com/1238181 based on http://wiki.apache.org/couchdb/ExternalProcesses#Example_External_Process
This file contains hidden or 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
import sys, json | |
class External(object): | |
def run(self): | |
line = sys.stdin.readline() | |
while line: | |
try: | |
response = self.process(json.loads(line.decode('utf_8'))) | |
except Exception, e: | |
response = {'code':500, 'json':{'error':True, 'reason':"Internal error processing request (%s)" % e}} | |
sys.stdout.write("%s\n" % json.dumps(response)) | |
sys.stdout.flush() | |
line = sys.stdin.readline() | |
def process(self, req): | |
res = {} | |
# TODO: set res['body'] or res['json'] based on req['method']/req['body']/req['path']/etc. | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created another class to extend it:
The password_checker is my external... and it only runs on 1,3,5 etc attempts... no log output whatsoever on 2,4,6,etc