changeset 32:ea7017439ab9

parameter f?r getPurls added
author dwinter
date Thu, 15 Aug 2013 09:02:04 +0200
parents 0190f49bce88
children aced422ae66c a25bfc49a068
files restService/getPurls.py restService/templates/registerPurls.html
diffstat 2 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/restService/getPurls.py	Thu Jun 06 05:55:09 2013 +0200
+++ b/restService/getPurls.py	Thu Aug 15 09:02:04 2013 +0200
@@ -22,22 +22,38 @@
         
         auth = web.ctx.env.get('HTTP_AUTHORIZATION')
       
+        params = web.input();
+        
         authreq = False
         if auth is None:#no authentification needed, SHOULD BE DONE VIA APACHE!!
             #authreq = True
-            username = "internal user (Please replace with your username)"
+            
+            
+            if params.get("user",None) is not None:
+                username = params.get("user")
+            else:
+                username = "internal user (Please replace with your username)"
+            
+            
+            
         else:
 
             auth = re.sub('^Basic ','',auth)
             username,password = base64.decodestring(auth).split(':')
             
+        
+        if params.get("number",None) is not None:
+            amount = params.get("number")
+        else:
+            amount =1
+            
             
         if authreq:
             web.header('WWW-Authenticate','Basic realm="Auth example"')
             web.ctx.status = '401 Unauthorized'
             return
         
-        return self.render.registerPurls(username)
+        return self.render.registerPurls(username,amount)
     
     def POST(self):
         inp = web.input()
--- a/restService/templates/registerPurls.html	Thu Jun 06 05:55:09 2013 +0200
+++ b/restService/templates/registerPurls.html	Thu Aug 15 09:02:04 2013 +0200
@@ -1,8 +1,8 @@
-$def with (username)
+$def with (username,amount)
 <h2>Create Purls</h2>
 
 <form method="post">
 <div>Username (if existing your mpiwg username):<input type="text" size="30" name="userName" value="$username"></div>
-<div>How many PURLS do you need (maximum 10):<input type="text" size="5" name="amount"></div>
+<div>How many PURLS do you need (maximum 10):<input type="text" size="5" name="amount" value="$amount"></div>
 <div><input type="submit"/></div>
 </form>
\ No newline at end of file