def generate_file_etag(path): file_info = os.stat(path) return hex(file_info[6] + file_info[8]) def generate_guid(): """ Generates a GUID string. The GUID length is 32 characters. It is used by the session manager to generate session IDs. @rtype: str """ return hashlib.md5(str(time.time()+time.clock()*1000)).hexdigest() generateGUID = deprecated(generate_guid) def generate_oid(): """ Generates an Object ID string. The generated ID is 8 characters long. @rtype: str """ return ''.join(random.sample(VALID_ID_CHRS, 8)) generateOID = deprecated(generate_oid) def get_rto_by_name(name): """ This function returns a runtime object by name.
Fetches an object from the database. If the user has no read permissions on the object or the item has been deleted then C{None} is returned. @param oid: The object's ID or the object's full path. @type oid: str @param trans: A valid transaction handle. @rtype: L{GenericItem<porcupine.systemObjects.GenericItem>} """ item = _db.get_item(oid, trans) if item != None and not item._isDeleted and \ permsresolver.get_access(item, currentThread().context.user) != 0: return item getItem = deprecated(get_item) def get_transaction(): """ Returns a transaction handle required for database updates. Currently, nested transactions are not supported. Subsequent calls to C{getTransaction} will return the same handle. @rtype: L{BaseTransaction<porcupine.db.basetransaction.BaseTransaction>} """ txn = currentThread().context.trans if txn == None: raise exceptions.InternalServerError, \ "The specified method is not defined as transactional." return txn getTransaction = deprecated(get_transaction)
# This file is part of Porcupine. # Porcupine is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # Porcupine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public License # along with Porcupine; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #=============================================================================== """ Deprecated module. Use "porcupine.utils.permsresolver instead" """ from porcupine.utils import permsresolver from porcupine.core.decorators import deprecated # 1 - read # 2 - update, delete if owner # 4 - update, delete anyway # 8 - full control NO_ACCESS = 0 READER = 1 AUTHOR = 2 CONTENT_CO = 4 COORDINATOR = 8 getAccess = deprecated(permsresolver.get_access)