def update(self, data):
    "Updates an object based on values contained inside the data dictionary"
    context = HttpContext.current()
    # get user role
    iUserRole = objectAccess.getAccess(self, context.user)
    if data.has_key('__rolesinherited') and iUserRole == objectAccess.COORDINATOR:
        self.inheritRoles = data.pop('__rolesinherited')
        if not self.inheritRoles:
            acl = data.pop('__acl')
            if acl:
                security = {}
                for descriptor in acl:
                    security[descriptor['id']] = int(descriptor['role'])
                self.security = security

    for prop in data:
        oAttr = getattr(self, prop)
        if isinstance(oAttr, datatypes.File):
            # see if the user has uploaded a new file
            if data[prop]['tempfile']:
                oAttr.filename = data[prop]['filename']
                sPath = context.server.temp_folder + '/' + data[prop]['tempfile']
                oAttr.loadFromFile(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.getTransaction()
    self.update(txn)
    return True
def resetPassword(self, new_password):
    "Resets the user's password"
    txn = db.getTransaction()
    self.password.value = new_password
    self.update(txn)
    txn.commit()
    return True
def rename(self, newName):
    "Changes the display name of an object"
    txn = db.getTransaction()
    self.displayName.value = newName
    self.update(txn)
    txn.commit()
    return True
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.getTransaction()
    activeUser.update(txn)
    return True
def create(self, data):
    "Creates a new item"
    context = HttpContext.current()
    oNewItem = misc.getCallableByName(data.pop('CC'))()

    # get user role
    iUserRole = objectAccess.getAccess(self, context.session.user)
    if data.has_key('__rolesinherited') and iUserRole == objectAccess.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.getTransaction()
    oNewItem.appendTo(self, txn)
    txn.commit()
    return oNewItem.id
def delete(self):
    "Removes the deleted item"
    txn = db.getTransaction()
    self.delete(txn)
    txn.commit()
    return True
def restoreTo(self, targetid):
    "Restores the deleted item to the designated target container"
    txn = db.getTransaction()
    self.restoreTo(targetid, txn)
    txn.commit()
    return True
def restore(self):
    "Restores the deleted item to its orginal location"
    txn = db.getTransaction()
    self.restore(txn)
    txn.commit()
    return True
def empty(self):
    "Empties the bin"
    txn = db.getTransaction()
    self.empty(txn)
    txn.commit()
    return True
def deletePermanent(self):
    txn = db.getTransaction()
    self.delete(txn)
    return True
def delete(self):
    txn = db.getTransaction()
    self.recycle('rb', txn)
    return True
def moveTo(self, targetid):
    txn = db.getTransaction()
    self.moveTo(targetid, txn)
    return True
def copyTo(self, targetid):
    txn = db.getTransaction()
    self.copyTo(targetid, txn)
    return True