labpack/databases/couchbase.py
def create_session(self, uid, duration=0):

        '''
            a method to create a session token for the user
            
        :param uid: string with id of user in bucket
        :param duration: integer with number of seconds to last (default: 24hrs) 
        :return: dictionary with account fields for user
        '''
    
        title = '%s.create_session' % self.__class__.__name__
        
    # validate inputs
        input_fields = {
            'uid': uid,
            'duration': duration
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
        
    # construct request fields
        url = self.bucket_url + '/_session'
        json_data = {
            'name': uid
        }
        if duration:
            json_data['ttl'] = duration
    
    # send request and unwrap response
        response = requests.post(url, json=json_data)
        response = response.json()
    
        return response

            a method to create a session token for the user
            
        :param uid: string with id of user in bucket
        :param duration: integer with number of seconds to last (default: 24hrs) 
        :return: dictionary with account fields for user
        
a method to create a session token for the user
a method to create a session token for the user
def create_session(self, uid, duration=0):
        title = '%s.create_session' % self.__class__.__name__
        input_fields = {
            'uid': uid,
            'duration': duration
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)
        url = self.bucket_url + '/_session'
        json_data = {
            'name': uid
        }
        if duration:
            json_data['ttl'] = duration
        response = requests.post(url, json=json_data)
        response = response.json()
        return response
def create_session ( self , uid , duration = 0 ) : title = '%s.create_session' % self . __class__ . __name__ input_fields = { 'uid' : uid , 'duration' : duration } for key , value in input_fields . items ( ) : if value : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) url = self . bucket_url + '/_session' json_data = { 'name' : uid } if duration : json_data [ 'ttl' ] = duration response = requests . post ( url , json = json_data ) response = response . json ( ) return response
a method to create a session token for the user
a method to create a session token for the user
'''
            a method to create a session token for the user
            
        :param uid: string with id of user in bucket
        :param duration: integer with number of seconds to last (default: 24hrs) 
        :return: dictionary with account fields for user
        ''' # validate inputs # construct request fields # send request and unwrap response
dictionary with account fields for user
dictionary with account fields for user
self
uid
string with id of user in bucket
string with id of user in bucket
duration
integer with number of seconds to last (default: 24hrs)
integer with number of seconds to last ( default : 24hrs )