def applySettings(self, data):
    "Saves user's preferences"
    context = HttpContext.current()
    activeUser = context.original_user
    for key in data:
        activeUser.settings.value[key] = data[key]
    txn = db.get_transaction()
    activeUser.update(txn)
    return True
def create(self, data):
    "Creates a new item"
    context = HttpContext.current()
    oNewItem = misc.get_rto_by_name(data.pop('CC'))()

    # get user role
    iUserRole = permsresolver.get_access(self, context.user)
    if data.has_key('__rolesinherited') and \
            iUserRole == permsresolver.COORDINATOR:
        oNewItem.inheritRoles = data.pop('__rolesinherited')
        if not oNewItem.inheritRoles:
            acl = data.pop('__acl')
            if acl:
                security = {}
                for descriptor in acl:
                    security[descriptor['id']] = int(descriptor['role'])
                oNewItem.security = security

    # set props
    for prop in data:
        oAttr = getattr(oNewItem, prop)
        if isinstance(oAttr, datatypes.File):
            if data[prop]['tempfile']:
                oAttr.filename = data[prop]['filename']
                sPath = context.server.temp_folder + '/' + data[prop]['tempfile']
                oAttr.loadFromFile(sPath)
                os.remove(sPath)
        elif isinstance(oAttr, datatypes.Date):
            oAttr.value = data[prop].value
        elif isinstance(oAttr, datatypes.Integer):
            oAttr.value = int(data[prop])
        else:
            oAttr.value = data[prop]
            
    txn = db.get_transaction()
    oNewItem.append_to(self, txn)
    return oNewItem.id
Ejemplo n.º 3
0
 def set_userid(self, value):
     self.__userid = value
     trans = db.get_transaction()
     self.update(trans)
Ejemplo n.º 4
0
 def set_value(self, name, value):
     self.__data[name] = value
     trans = db.get_transaction()
     self.update(trans)
def delete(self):
    "Removes the deleted item"
    txn = db.get_transaction()
    self.delete(txn)
    return True
def restoreTo(self, targetid):
    "Restores the deleted item to the designated target container"
    txn = db.get_transaction()
    self.restore_to(targetid, txn)
    return True
def restore(self):
    "Restores the deleted item to its orginal location"
    txn = db.get_transaction()
    self.restore(txn)
    return True
Ejemplo n.º 8
0
def resetPassword(self, new_password):
    "Resets the user's password"
    txn = db.get_transaction()
    self.password.value = new_password
    self.update(txn)
    return True
 def revive_session(self, session):
     trans = db.get_transaction()
     session.update(trans)
 def remove_session(self, sessionid):
     trans = db.get_transaction()
     session = db._db.get_item(sessionid, trans)
     session.delete(trans)
 def create_session(self, userid):
     trans = db.get_transaction()
     session = schema.Session(userid, {})
     session.append_to('_sessions', trans)
     return session