Changeset 6949 for cows_wps


Ignore:
Timestamp:
08/06/10 14:04:09 (9 years ago)
Author:
astephen
Message:

various fixes to get user picked up and cookies working.

Location:
cows_wps/trunk/cows_wps
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/cows_wps/controllers/submitter.py

    r6947 r6949  
    44import logging 
    55import urllib 
     6import urllib2 
     7import Cookie 
     8import datetime 
    69 
    710from pylons import request, response, session, tmpl_context as c 
     
    7578        base_url = "http://" + request.url[7:].split("/")[0] 
    7679        full_url = base_url + wps_request_url 
    77        # return full_url 
    78         """getter = urllib.urlopen(full_url) 
     80        #return full_url 
     81 
     82#        full_url = "http://badc.nerc.ac.uk/data/rules.html" 
     83        clean_request_url = base_url + urllib.unquote(wps_request_url) 
     84        req = urllib2.Request(url = clean_request_url) 
     85        cookies = request.cookies 
     86 
     87        expiration = datetime.datetime.now() + datetime.timedelta(days=30) 
     88 
     89        for cookie in cookies.items(): 
     90            nc = Cookie.SimpleCookie() 
     91            (k, v) = cookie 
     92            log.warn("COOKIE: %s = %s" % (k, v)) 
     93            nc[k] = v 
     94            nc[k]["domain"] = "ceda-wps1.badc.rl.ac.uk" 
     95            nc[k]["path"] = "/" 
     96            nc[k]["expires"] = expiration.strftime("%a, %d-%b-%Y %H:%M:%S PST") 
     97            req.add_header('Cookie', nc.output()) 
     98 
     99       # return clean_request_url  
     100#        getter = urllib.urlopen(clean_request_url) 
     101        getter = urllib2.urlopen(req) 
    79102        xml = getter.read() 
    80103        getter.close() 
    81         """ 
    82  
    83         clean_request_url = urllib.unquote(wps_request_url) 
    84         xml = request.environ['paste.recursive.include'](clean_request_url) 
    85         return str(xml) 
     104#        return str(xml) 
    86105 
    87106 
  • cows_wps/trunk/cows_wps/controllers/test.py

    r6947 r6949  
    7171        resp = openIdAxParams["emailAddress"] 
    7272        return resp 
     73 
     74    def cookies(self): 
     75        import cookielib 
     76        cj = cookielib.CookieJar()  
     77        #return str(cj) 
     78        cookies = request.cookies.items() 
     79        resp = "" 
     80        for (k, v) in cookies: 
     81            resp += "<b>%s</b> = %s<br>" % (k, v) 
     82 
     83        import Cookie 
     84        k = Cookie.SimpleCookie() 
     85        k["ndg.security.session"] = "96bb6499953f3853bd4c36564fa6e266f239b11f232902baee883ece2ac5e73d91fdcbbb" 
     86 
     87        return resp 
  • cows_wps/trunk/cows_wps/controllers/wps.py

    r6947 r6949  
    221221#            raise OwsError("User %s is not logged into the system." % (username)) 
    222222 
    223         # Get username and e-mail address 
     223        # Get username and e-mail address from secure session 
    224224        try: 
    225225            um = UserManager() 
     226            email = um.getEmailAddress() 
     227            username = um.getUserName() 
    226228        except: 
    227             raise OwsError("Cannot find security information to access user details.") 
    228  
    229         email = um.getEmailAddress() 
    230         username = um.getUserName() 
     229            log.warn("Setting user to 'anon' because security implies this requires no login.") 
     230            username = "anon" 
     231            email = "" 
    231232 
    232233        log.debug("identifier=%s, username=%s, requestId=%s costonly=%s lineage=%s inform=%s" % \ 
     
    307308                        processQueue = self._selectQueue(identifier, process_type) 
    308309                         
    309                         self._submitAsyncProcess(identifier, requestId, context, processQueue) 
     310                        self._submitAsyncProcess(identifier, requestId, username, context, processQueue) 
    310311                    else: 
    311312                        context.setStatus(STATUS.FAILED, message) 
     
    319320             
    320321                 
    321             requestManager.addSyncRequest(requestId, identifier, context) 
     322            requestManager.addSyncRequest(requestId, username, identifier, context) 
    322323                               
    323324            if hasattr(processCallable, 'dryRun'): 
     
    440441        return processQueue 
    441442         
    442     def _submitAsyncProcess(self, identifier, jobId, context, queue): 
     443    def _submitAsyncProcess(self, identifier, jobId, username, context, queue): 
    443444        """ 
    444445        Submits an asynchronous process and returns updated Exec Resp doc. 
     
    474475        else: 
    475476            log.debug('submit sge_job_id to requestManager to add it to the job id mapping file') 
    476             requestManager.addAsyncRequest(jobId, sge_job_id, identifier, context, queue) 
     477            requestManager.addAsyncRequest(jobId, username, sge_job_id, identifier, context, queue) 
    477478             
    478479        finally: 
  • cows_wps/trunk/cows_wps/lib/request.py

    r5615 r6949  
    432432            return False 
    433433 
    434     def addAsyncRequest(self, requestId, sgeJobId, identifier, context, queue=""): 
     434    def addAsyncRequest(self, requestId, username, sgeJobId, identifier, context, queue=""): 
    435435        """ 
    436436        Creates new Request and SGEJob objects and then adds them to the database. 
     
    444444            raise ValueError('Maximum RequestID length is %d, %d given' % (MAX_REQUEST_ID_LENGTH, len(requestId))) 
    445445 
    446         user_id = self._getUsername(context) 
     446        user_id = username ###self._getUsername(context) 
    447447 
    448448        session = self.getSession() 
     
    469469        return req 
    470470                
    471     def addSyncRequest(self, requestId, identifier, context): 
     471    def addSyncRequest(self, requestId, username, identifier, context): 
    472472        """ 
    473473        Creates new Request and InThreadJob objects and then adds them to the database. 
     
    481481            raise ValueError('Maximum RequestID length is %d, request %s has length %d ' % (MAX_REQUEST_ID_LENGTH, requestId, len(requestId))) 
    482482 
    483         user_id = self._getUsername(context) 
     483        user_id = username ###self._getUsername(context) 
    484484         
    485485        session = self.getSession() 
     
    736736            session.close()  
    737737 
    738     def _getUsername(self, context): 
     738    def DEPRECATED_getUsername(self, context): 
    739739        """ 
    740740        Extracts the 'Username' value from the context.inputs dictionary, if no entry is found then 
  • cows_wps/trunk/cows_wps/wsgiapp.py

    r6947 r6949  
    99from paste.urlparser import StaticURLParser 
    1010from paste.deploy.converters import asbool 
    11  
    12 # Allows internal redirect 
    13 from paste.recursive import RecursiveMiddleware 
    1411 
    1512from pylons import config 
     
    5249 
    5350 
    54 def make_app(global_conf, full_stack=True, **app_conf): 
     51def make_app(global_conf, full_stack = True, **app_conf): 
    5552    """Create a Pylons WSGI application and return it 
    5653 
     
    7875    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) 
    7976    app = RoutesMiddleware(app, config['routes.map']) 
    80     # To allow internal redirect 
    81     app = RecursiveMiddleware(app) 
    8277    app = SessionMiddleware(app, config) 
    8378    app = CacheMiddleware(app, config) 
    8479 
    8580 
    86     # Import managers here to triger instantiation in main thread. 
    87     #!TODO:  Should probably be instantiated here too and add to globals. 
     81    # Import managers here to trigger instantiation in main thread. 
    8882    import cows_wps.model.managers 
    8983 
Note: See TracChangeset for help on using the changeset viewer.