Ejemplo n.º 1
0
def blipChanges(blip_id, key=None, session=None):
    '''
    Marks a single blip unread for this user. Supply one of the optional
    arguments. Supplying session is always more efficient if you
    already have the value
    @param key=None: a dict containing wave_id, wavelet_id and email
    @param session=None: the parent session object
    @param blip_id: the blip that is to be marked read
    '''
    if blip_id == None:
        return
    if session == None:
        session = sessionTools.get(key['wave_id'], key['wavelet_id'], key['email'])     

    def worker(session, blip_id):
        '''
        @transaction_safe
        '''
        settings = get(session)
        if settings:
            if blip_id in settings.read_blips:
                settings.read_blips.remove(blip_id)
                put(settings, session.wave_id, session.wavelet_id, session.email)

    db.run_in_transaction(worker, session, blip_id)
Ejemplo n.º 2
0
def changeRWPermission(new_permission, key=None, session=None):
    '''
    Changes the RW permission for this session. Supply one of the optional
    arguments. Supplying session is always more efficient if you already have
    the value.
    @param key=None: a dict containing wave_id, wavelet_id and email
    @param session=None: the parent session object
    @param new_permission: the raw permission type to give this session
    '''
    if session == None:
        session = sessionTools.get(key['wave_id'], key['wavelet_id'], key['email'])
    
    def worker(session, new_permission):
        '''
        @transaction_safe
        '''
        settings = get(session)
        settings.rw_permission = new_permission
        put(settings, session.wave_id, session.wavelet_id, session.email)

    db.run_in_transaction(worker, session, new_permission)
    
Ejemplo n.º 3
0
def _updateUnseenChanges(wave_id, wavelet_id, email, value, session):
    '''
    Changes the value of unseen_changes in a nice transaction safe way
    @param wave_id: the wave id of the session to modify
    @param wavelet_id: the wavelet id of the session to modify
    @param email: the email of the session to modify
    @param value: the new value for unseen_changes
    @param session: if provided uses given session, if None fetches from db
    '''
    if session == None:
        session = sessionTools.get(wave_id, wavelet_id, email)

    def worker(session, wave_id, wavelet_id, email, value):
        '''
        @transaction_safe
        '''
        settings = get(session)
        if settings:
            settings.unseen_changes = value
            put(settings, wave_id, wavelet_id, email)

    db.run_in_transaction(worker, session, wave_id, wavelet_id, email, value)