From b3dbc58548ade1b1590ce7679eb2f1ec45e94305 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Mon, 24 Apr 2006 09:39:49 +0000 Subject: [PATCH] Unused file. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6878 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Tool/RouteTool.py | 85 -------------------- product/ERP5/Tool/TestSched.py | 139 --------------------------------- 2 files changed, 224 deletions(-) delete mode 100644 product/ERP5/Tool/RouteTool.py delete mode 100644 product/ERP5/Tool/TestSched.py diff --git a/product/ERP5/Tool/RouteTool.py b/product/ERP5/Tool/RouteTool.py deleted file mode 100644 index 43147ba9cf..0000000000 --- a/product/ERP5/Tool/RouteTool.py +++ /dev/null @@ -1,85 +0,0 @@ -############################################################################## -# -# Copyright (c) 2005 Nexedi SARL and Contributors. All Rights Reserved. -# Romain Courteaud <romain@nexedi.com> -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsability of assessing all potential -# consequences resulting from its eventual inadequacies and bugs -# End users who are looking for a ready-to-use solution with commercial -# garantees and support are strongly adviced to contract a Free Software -# Service Company -# -# This program is Free Software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -############################################################################## - -from Products.CMFCore.utils import UniqueObject - -from AccessControl import ClassSecurityInfo -from Globals import InitializeClass, DTMLFile -from Products.ERP5Type.Document.Folder import Folder -from Products.ERP5Type import Permissions - -from Products.ERP5 import _dtmldir - -from zLOG import LOG - -class RouteTool(UniqueObject, Folder): - """ - The RouteTool implements portal object - expand policies. - - Status : not ready - - """ - id = 'portal_routes' - meta_type = 'ERP5 Route Tool' - portal_type = 'Route Tool' - allowed_types = () - - # Declarative Security - security = ClassSecurityInfo() - - # - # ZMI methods - # - manage_options = ( ( { 'label' : 'Overview' - , 'action' : 'manage_overview' - } - , - ) - + Folder.manage_options - ) - - security.declareProtected( Permissions.ManagePortal, 'manage_overview' ) - manage_overview = DTMLFile( 'explainRouteTool', _dtmldir ) - - # Filter content (ZMI)) - def __init__(self): - return Folder.__init__(self, RouteTool.id) - - # Filter content (ZMI)) - def filtered_meta_types(self, user=None): - # Filters the list of available meta types. - all = RouteTool.inheritedAttribute('filtered_meta_types')(self) - meta_types = [] - for meta_type in self.all_meta_types(): - if meta_type['name'] in self.allowed_types: - meta_types.append(meta_type) - return meta_types - - -InitializeClass(RouteTool) diff --git a/product/ERP5/Tool/TestSched.py b/product/ERP5/Tool/TestSched.py deleted file mode 100644 index 70ea6454c4..0000000000 --- a/product/ERP5/Tool/TestSched.py +++ /dev/null @@ -1,139 +0,0 @@ - -from threading import Thread, Event - -class Scheduler: - """ - Step 1: use lists - - Step 2: add some object related dict which prevents calling twice the same method - - Step 3: add some time information for deferred execution - - Step 4: use MySQL as a way to store events (with locks) - - Step 5: use periodic Timer to wakeup Scheduler - - Step 6: add multiple threads on a single Scheduler - - Step 7: add control thread to kill "events which last too long" - - Some data: - - - reindexObject = 50 ms - - - calling a MySQL read = 0.7 ms - - - calling a simple method by HTTP = 30 ms - - - calling a complex method by HTTP = 500 ms - - References: - - http://www.mysql.com/doc/en/InnoDB_locking_reads.html - http://www.python.org/doc/current/lib/thread-objects.html - """ - - def __init__(self): - self.is_alive = 1 - self.queue = [] - self.wakeup_event = Event() - self.thread = Thread(target = self.run) - self.thread.start() - - def queueMessage(self, m): - self.queue.append(m) - self.wakeup_event.set() - - def dequeueMessage(self): - m = self.queue[0] - m() - del self.queue[0] - - def run(self): - while self.is_alive: - if self.main(): - self.sleep() - self.wait() - - def wait(self): - self.wakeup_event.wait() - - def sleep(self): - self.wakeup_event.clear() - - def wakeup(self): - self.wakeup_event.set() - - def terminate(self): - self.is_alive = 0 - - def main(self): - if len(self.queue) is 0: - return 1 # Sleep - else: - self.dequeueMessage() - return 0 - -main_scheduler = Scheduler() - -class Message: - def __init__(self, object, method_id, *args, **kw): - self.object = object - self.method_id = method_id - self.args = args - self.kw = kw - # User Info ? - - def __call__(self): - getattr(self.object,self.method_id)(*self.args, **self.kw) - -class Method: - - def __init__(self, passive_self, method_id): - self.passive_self = passive_self - self.method_id = method_id - - def __call__(self, *args, **kw): - m = Message(self.passive_self, self.method_id, *args, **kw) - main_scheduler.queueMessage(m) - -class ActiveObject: - - def __init__(self, passive_self): - self.__dict__['passive_self'] = passive_self - - def __getattr__(self, id): - return Method(self.__dict__['passive_self'], id) - -class Test: - - toto = 0 - active_wrapper = None - - def incToto(self, v, foo=0): - self.toto = self.toto + v + foo - - def activate(self): - if self.active_wrapper is None: self.active_wrapper = ActiveObject(self) - return self.active_wrapper - -o = Test() -a = o.activate() - -# Test -print 'Begin', o.toto -o.incToto(1) -print 'Inc Result +1', o.toto -o.activate().incToto(2) -print 'Active Inc Result +2', o.toto -o.activate().incToto(3, foo=100) -print 'Active Inc Result +3 foo', o.toto -#main_scheduler.dequeueMessage() -#print 'Dequeu Result', o.toto -#main_scheduler.dequeueMessage() -#print 'Dequeu Result', o.toto -# while o.toto < 100: -# print 'Run', o.toto -# print 'Run', o.toto -# print 'Run', o.toto -#main_scheduler.terminate() \ No newline at end of file -- 2.30.9