Пример #1
0
    def create(cls,
               command,
               transaction_data,
               description,
               title='',
               state=None):
        user_name = Environment.get_user_name()
        #namespace = Environment.get_env_object().get_context_name()
        from pyasm.biz import Project
        namespace = Project.get_global_project_code()

        # TODO: need to add a ticket column to the transaction_log table
        security = Environment.get_security()
        ticket = security.get_ticket_key()

        #transaction_data = transaction_data.replace("\\", "\\\\")

        length_before = len(transaction_data)
        cutoff = 10 * 1024
        if length_before > cutoff:
            import zlib, binascii
            transaction_data = Common.process_unicode_string(transaction_data)
            ztransaction_data = binascii.hexlify(
                zlib.compress(transaction_data))
            ztransaction_data = "zlib:%s" % ztransaction_data
            length_after = len(ztransaction_data)
            print "transaction log compress: ", "%s%%" % int(
                float(length_after) / float(length_before) *
                100), "[%s] to [%s]" % (length_before, length_after)
        else:
            ztransaction_data = transaction_data

        # a new entry deletes all redos for that user
        TransactionLog.delete_all_redo()

        log = SObjectFactory.create("sthpw/transaction_log")
        log.set_value("login", user_name)
        log.set_value("command", command)
        log.set_value("transaction", ztransaction_data)
        log.set_value("title", title)
        log.set_value("description", description)
        log.set_value("type", "undo")
        log.set_value("namespace", namespace)
        log.set_value("ticket", ticket)
        if state:
            log.set_value("state", state)

        server = Config.get_value("install", "server")
        if server:
            log.set_value("server_code", server)

        log.commit(triggers=False)

        # FIXME:
        # only do an sobject log before the cutoff ... above this it gets
        # very slow.  Need a way of doing very fast inserts
        if length_before <= cutoff:
            cls.create_sobject_log(log, transaction_data)
        return log
Пример #2
0
    def create(cls, command, transaction_data, description, title='', state=None, keywords=None):
        user_name = Environment.get_user_name()
        #namespace = Environment.get_env_object().get_context_name()
        from pyasm.biz import Project
        namespace = Project.get_global_project_code()

        # TODO: need to add a ticket column to the transaction_log table
        security = Environment.get_security()
        ticket = security.get_ticket_key()

        #transaction_data = transaction_data.replace("\\", "\\\\")

        length_before = len(transaction_data)
        cutoff = 10*1024
        if length_before > cutoff:
            import zlib, binascii
            transaction_data = Common.process_unicode_string(transaction_data)
            ztransaction_data = binascii.hexlify(zlib.compress(transaction_data))
            ztransaction_data = "zlib:%s" % ztransaction_data
            length_after = len(ztransaction_data)
            print "transaction log compress: ", "%s%%" % int(float(length_after)/float(length_before)*100), "[%s] to [%s]" % (length_before, length_after)
        else:
            ztransaction_data = transaction_data

        # a new entry deletes all redos for that user
        TransactionLog.delete_all_redo()


        log = SObjectFactory.create("sthpw/transaction_log")
        log.set_value("login", user_name)
        log.set_value("command", command)
        log.set_value("transaction", ztransaction_data)
        log.set_value("title", title)
        log.set_value("description", description)
        log.set_value("type", "undo")
        log.set_value("namespace", namespace)
        log.set_value("ticket", ticket)
        if state:
            log.set_value("state", state)

        if keywords:
            log.set_value("keywords", keywords)

        server = Config.get_value("install", "server")
        if server:
            log.set_value("server_code", server)

        log.commit(triggers=False)



        # FIXME:
        # only do an sobject log before the cutoff ... above this it gets
        # very slow.  Need a way of doing very fast inserts
        if length_before <= cutoff:
            cls.create_sobject_log(log, transaction_data)
        return log
Пример #3
0
    def get_by_ticket(ticket):
        search = Search(TransactionState)
        search.add_filter("ticket", ticket)
        state = search.get_sobject()

        # create the state data for this ticket
        if not state:
            state = SObjectFactory.create(TransactionState.SEARCH_TYPE)
            state.set_value("ticket", ticket)
            data = Xml()
            data.create_doc("state")
            state.set_value("data", data.to_string() )
            state.commit()

        return state
Пример #4
0
    def get_by_ticket(ticket):
        search = Search(TransactionState)
        search.add_filter("ticket", ticket)
        state = search.get_sobject()

        # create the state data for this ticket
        if not state:
            state = SObjectFactory.create(TransactionState.SEARCH_TYPE)
            state.set_value("ticket", ticket)
            data = Xml()
            data.create_doc("state")
            state.set_value("data", data.to_string())
            state.commit()

        return state