# HG changeset patch # User dwinter # Date 1382524051 -7200 # Node ID a25bfc49a068371c555ac034df1a24e349850163 # Parent ea7017439ab9803da44005f09bc4856defd1e43a added format parameter diff -r ea7017439ab9 -r a25bfc49a068 restService/getPurls.py --- a/restService/getPurls.py Thu Aug 15 09:02:04 2013 +0200 +++ b/restService/getPurls.py Wed Oct 23 12:27:31 2013 +0200 @@ -61,25 +61,41 @@ username=inp.get("userName",None) amount=inp.get("amount",None) + outFormat=inp.get("format","html") + if (username==None) or (amount==None): - raise web.badrequest("Username and amount have to be send!") + raise web.badrequest("UserName and amount have to be send!") try: amount=int(amount) except: raise web.badrequest("Amount is not an integer!") - if amount>10: + if amount>1000: raise web.badrequest("Amount is to large (maximum 10)") purls=[] for i in range(amount): purls.append(self.purlManager.register(user=username)) - - return self.render.registeredPurlsResponse(purls) - + if outFormat == "html": + return self.render.registeredPurlsResponse(purls) + elif outFormat == "plain": + ret="" + for p in purls: + ret+="%s\n"%p[1] + web.header('Content-Type', 'text/plain') + return ret + elif outFormat == "plain-noPrefix": + ret="" + for p in purls: + ret+="%s\n"%p[1].replace("MPIWG:","") + + web.header('Content-Type', 'text/plain') + return ret + else: + raise web.badrequest("Allowed parameters for format are only html, plain and plain-noPrefix. The default is html was %s.."%outFormat) class randomSearch: def __init__(self): diff -r ea7017439ab9 -r a25bfc49a068 restService/images.py --- a/restService/images.py Thu Aug 15 09:02:04 2013 +0200 +++ b/restService/images.py Wed Oct 23 12:27:31 2013 +0200 @@ -36,7 +36,6 @@ path=doc.get('TT_image',None) - if (path is not None) and (not isinstance(path, basestring)): #TT_image was defined as multiple , shouldn't be the case ? path=path[0] diff -r ea7017439ab9 -r a25bfc49a068 restService/templates/serviceDescription.html --- a/restService/templates/serviceDescription.html Thu Aug 15 09:02:04 2013 +0200 +++ b/restService/templates/serviceDescription.html Wed Oct 23 12:27:31 2013 +0200 @@ -50,7 +50,7 @@ GET: returns an simple web page to enter username and amount of purls needed -POST: expects the parameter "username" and "amount"", return list of purls +POST: expects the parameter "userName" and "amount"", return list of purls