def open(self): # online_manager.wsockets.append(self) # if not 'sessionid' in self.request.cookies: self.close() return # path is the room where the user is arriving # we create a room per registred user ? session_id = self.request.cookies['sessionid'].value # get django session data try: session = Session.objects.get(session_key=session_id) session_data = session.get_decoded() except Session.DoesNotExist: session_data = {} session_data['akey'] = AppManager.get_new_uuid() #return # akey = session_data['akey'] self.request.akey = akey self.request.path = akey from ilot.core.models import Item try: actor = Item.objects.get(id=akey) except ObjectDoesNotExist: actor = Item(id=akey, locale=akey, context=akey, origin_id=akey, target=akey, related_id=akey, akey=akey, status='newVisitor') actor.save() # generate wkey ? wkey = online_manager.get_contact_uuid() online_manager.akey_by_wkey[wkey] = akey online_manager.register_online(self, wkey) #online_manager.join_network() # send it to the connecting user kwargs = { 'context':session_data['akey'], 'path':session_data['akey'], 'input_data':{}, 'action':'index', 'ext':'.html', 'do':True, 'todo':True, 'text':'Welcome to the network. Please Authenticate or register', }
def get_request_akey(cls, request): """ Get actionpipe data container key Generates a new one if missing cookie """ akey = None if cls.pipe_hash_key in request.session: akey = request.session[cls.pipe_hash_key] if not akey: akey = AppManager.get_new_uuid() request.session[cls.pipe_hash_key] = akey return akey