changeset 35:d3ecbfd21e06

Merge with a25bfc49a068371c555ac034df1a24e349850163
author dwinter
date Wed, 23 Oct 2013 12:28:22 +0200
parents aced422ae66c (current diff) a25bfc49a068 (diff)
children be8640c08d99
files restService/templates/serviceDescription.html
diffstat 3 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/restService/getPurls.py	Wed Aug 28 12:57:36 2013 +0200
+++ b/restService/getPurls.py	Wed Oct 23 12:28:22 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):
       
--- a/restService/images.py	Wed Aug 28 12:57:36 2013 +0200
+++ b/restService/images.py	Wed Oct 23 12:28:22 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]
         
--- a/restService/templates/serviceDescription.html	Wed Aug 28 12:57:36 2013 +0200
+++ b/restService/templates/serviceDescription.html	Wed Oct 23 12:28:22 2013 +0200
@@ -54,7 +54,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
 
 <h3>/purls/searchSolr?text-url-path=PATH</h3>