[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py restore ability to set sockname from command line
Log message for revision 115616: restore ability to set sockname from command line Changed: U Zope/trunk/src/Zope2/Startup/zopectl.py -=- Modified: Zope/trunk/src/Zope2/Startup/zopectl.py === --- Zope/trunk/src/Zope2/Startup/zopectl.py 2010-08-10 06:58:11 UTC (rev 115615) +++ Zope/trunk/src/Zope2/Startup/zopectl.py 2010-08-10 07:10:01 UTC (rev 115616) @@ -122,6 +122,10 @@ # the command line option can set this. program = None +# this indicates that no explict socket name has been provided. +# the command line option can set this. +sockname = None + # XXX Suppress using Zope's eventlog section to avoid using the # same logging for zdctl as for the Zope appserver. There still # needs to be a way to set a logfile for zdctl. @@ -178,7 +182,10 @@ self.program = config.runner.program else: self.program = [os.path.join(self.directory, bin, runzope)] -if config.runner and config.runner.socket_name: +if self.sockname: +# set by command line option +pass +elif config.runner and config.runner.socket_name: self.sockname = config.runner.socket_name else: self.sockname = os.path.join(self.clienthome, zopectlsock) ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py allow the -p option to zopectl to work again, handy for buildout-based zope instances
Log message for revision 115377: allow the -p option to zopectl to work again, handy for buildout-based zope instances Changed: U Zope/trunk/src/Zope2/Startup/zopectl.py -=- Modified: Zope/trunk/src/Zope2/Startup/zopectl.py === --- Zope/trunk/src/Zope2/Startup/zopectl.py 2010-08-02 11:53:26 UTC (rev 115376) +++ Zope/trunk/src/Zope2/Startup/zopectl.py 2010-08-02 13:38:05 UTC (rev 115377) @@ -114,11 +114,14 @@ positional_args_allowed = 1 -program = zopectl schemadir = os.path.dirname(Zope2.Startup.__file__) schemafile = zopeschema.xml uid = gid = None +# this indicates that no explict program has been provided. +# the command line option can set this. +program = None + # XXX Suppress using Zope's eventlog section to avoid using the # same logging for zdctl as for the Zope appserver. There still # needs to be a way to set a logfile for zdctl. @@ -169,7 +172,9 @@ config = self.configroot self.directory = config.instancehome self.clienthome = config.clienthome -if config.runner and config.runner.program: +if self.program: +self.program = [self.program] +elif config.runner and config.runner.program: self.program = config.runner.program else: self.program = [os.path.join(self.directory, bin, runzope)] ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] SVN: Zope/branches/2.12/doc/ Merge 'tseaver-clarify_install_docs' branch.
Tres Seaver wrote: Log message for revision 109858: Merge 'tseaver-clarify_install_docs' branch. Thanks for waiting until there was consensus on this :-( That'll teach me to put any effort into helping with documentation and packaging... Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Fix for LP #61446: running zopectl in interactive mode on Windows exited after start/stop/install/remove commands were issued.
Log message for revision 105393: Fix for LP #61446: running zopectl in interactive mode on Windows exited after start/stop/install/remove commands were issued. Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-30 16:36:37 UTC (rev 105392) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-30 17:30:18 UTC (rev 105393) @@ -83,7 +83,8 @@ argv=argv, ) -return err,InstanceService +self.InstanceClass = InstanceService +return err return inner @@ -238,7 +239,7 @@ # Add extra commands to install and remove the Windows service def do_install(self,arg): -err,InstanceClass = do_windows('install')(self,arg) +err = do_windows('install')(self,arg) if not err: # If we installed successfully, put info in registry for the # real Service class to use: @@ -248,12 +249,13 @@ os.path.join(os.path.split(sys.argv[0])[0],'runzope'), self.options.configfile ) -InstanceClass.setReg('command',command) +self.InstanceClass.setReg('command',command) # This is unfortunately needed because runzope.exe is a setuptools # generated .exe that spawns off a sub process, so pid would give us # the wrong event name. - InstanceClass.setReg('pid_filename',self.options.configroot.pid_filename) + self.InstanceClass.setReg('pid_filename',self.options.configroot.pid_filename) +return err def help_install(self): print install -- Installs Zope as a Windows service. ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Fix zopectl status on Windows by borrowing from:
Log message for revision 105394: Fix zopectl status on Windows by borrowing from: http://svn.plone.org/svn/collective/buildout/plone.recipe.zope2instance/trunk/src/plone/recipe/zope2instance/ctl.py Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-30 17:30:18 UTC (rev 105393) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-30 18:26:59 UTC (rev 105394) @@ -51,15 +51,16 @@ WIN = False if sys.platform[:3].lower() == win: WIN = True +import pywintypes +import win32service import win32serviceutil from nt_svcutils import service def do_windows(command): def inner(self,arg): -INSTANCE_HOME = self.options.directory -name = 'Zope'+str(hash(INSTANCE_HOME.lower())) -display_name = 'Zope instance at '+INSTANCE_HOME +name = self.get_service_name() +display_name = 'Zope instance at '+self.options.directory # This class exists only so we can take advantage of # win32serviceutil.HandleCommandLine, it is never @@ -222,16 +223,26 @@ ## START OF WINDOWS ONLY STUFF if WIN: + +def get_service_name(self): +return 'Zope'+str(hash(self.options.directory.lower())) + def get_status(self): -# get_status from zdaemon relies on *nix specific socket handling. -# We just don't support getting the status and sending actions to -# the control server on Windows. This could be extended to ask for -# the status of the Windows service though -self.zd_up = 0 -self.zd_pid = 0 -self.zd_status = None -return +sn = self.get_service_name() +try: +stat = win32serviceutil.QueryServiceStatus(sn)[1] +self.zd_up = 1 +except pywintypes.error, err: +if err[0] == 1060: +# Service not installed +stat = win32service.SERVICE_STOPPED +self.zd_up = 0 +else: +raise +self.zd_pid = (stat == win32service.SERVICE_RUNNING) and -1 or 0 +self.zd_status = args=%s % self.options.program + do_start = do_windows('start') do_stop = do_windows('stop') do_restart = do_windows('restart') ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Don't whine and barf when someone hits Ctrl-C during zopectl fg on Windows.
Log message for revision 105395: Don't whine and barf when someone hits Ctrl-C during zopectl fg on Windows. Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-30 18:26:59 UTC (rev 105394) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-30 18:29:22 UTC (rev 105395) @@ -308,6 +308,8 @@ command = quote_command(program) try: return os.system(command) +except KeyboardInterrupt: +pass finally: for addition in local_additions: program.remove(addition) ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py merge changes from Zope 2.12 branch:
Log message for revision 105396: merge changes from Zope 2.12 branch: - fix LP #461446: zopectl in interactive mode exited when the start/stop/etc commands were used - zopectl status now works on Windows - zopectl fg doesn't bomb if you hit Ctrl-C in Windows anymore. Changed: U Zope/trunk/src/Zope2/Startup/zopectl.py -=- Modified: Zope/trunk/src/Zope2/Startup/zopectl.py === --- Zope/trunk/src/Zope2/Startup/zopectl.py 2009-10-30 18:29:22 UTC (rev 105395) +++ Zope/trunk/src/Zope2/Startup/zopectl.py 2009-10-30 18:35:26 UTC (rev 105396) @@ -51,15 +51,16 @@ WIN = False if sys.platform[:3].lower() == win: WIN = True +import pywintypes +import win32service import win32serviceutil from nt_svcutils import service def do_windows(command): def inner(self,arg): -INSTANCE_HOME = self.options.directory -name = 'Zope'+str(hash(INSTANCE_HOME.lower())) -display_name = 'Zope instance at '+INSTANCE_HOME +name = self.get_service_name() +display_name = 'Zope instance at '+self.options.directory # This class exists only so we can take advantage of # win32serviceutil.HandleCommandLine, it is never @@ -83,7 +84,8 @@ argv=argv, ) -return err,InstanceService +self.InstanceClass = InstanceService +return err return inner @@ -220,16 +222,26 @@ ## START OF WINDOWS ONLY STUFF if WIN: + +def get_service_name(self): +return 'Zope'+str(hash(self.options.directory.lower())) + def get_status(self): -# get_status from zdaemon relies on *nix specific socket handling. -# We just don't support getting the status and sending actions to -# the control server on Windows. This could be extended to ask for -# the status of the Windows service though -self.zd_up = 0 -self.zd_pid = 0 -self.zd_status = None -return +sn = self.get_service_name() +try: +stat = win32serviceutil.QueryServiceStatus(sn)[1] +self.zd_up = 1 +except pywintypes.error, err: +if err[0] == 1060: +# Service not installed +stat = win32service.SERVICE_STOPPED +self.zd_up = 0 +else: +raise +self.zd_pid = (stat == win32service.SERVICE_RUNNING) and -1 or 0 +self.zd_status = args=%s % self.options.program + do_start = do_windows('start') do_stop = do_windows('stop') do_restart = do_windows('restart') @@ -237,7 +249,7 @@ # Add extra commands to install and remove the Windows service def do_install(self,arg): -err,InstanceClass = do_windows('install')(self,arg) +err = do_windows('install')(self,arg) if not err: # If we installed successfully, put info in registry for the # real Service class to use: @@ -247,12 +259,13 @@ os.path.join(os.path.split(sys.argv[0])[0],'runzope'), self.options.configfile ) -InstanceClass.setReg('command',command) +self.InstanceClass.setReg('command',command) # This is unfortunately needed because runzope.exe is a setuptools # generated .exe that spawns off a sub process, so pid would give us # the wrong event name. - InstanceClass.setReg('pid_filename',self.options.configroot.pid_filename) + self.InstanceClass.setReg('pid_filename',self.options.configroot.pid_filename) +return err def help_install(self): print install -- Installs Zope as a Windows service. @@ -294,6 +307,8 @@ command = quote_command(program) try: return os.system(command) +except KeyboardInterrupt: +pass finally: for addition in local_additions: program.remove(addition) ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/ - rework Windows service stuff to make zopeservice.py in the instance home un-necessary
Log message for revision 104793: - rework Windows service stuff to make zopeservice.py in the instance home un-necessary (this means that buildout instances work on Windows too :-) ) - remove a few stray comments and old unneeded code from nt_svcutils/service.py Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py D Zope/branches/2.12/src/Zope2/utilities/skel/bin/zopeservice.py.in U Zope/branches/2.12/src/nt_svcutils/service.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 11:06:04 UTC (rev 104792) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 11:34:19 UTC (rev 104793) @@ -51,7 +51,42 @@ WIN = False if sys.platform[:3].lower() == win: WIN = True +import win32serviceutil +from nt_svcutils import service + +def do_windows(command): +def inner(self,arg): +INSTANCE_HOME = self.options.directory +name = 'Zope'+str(hash(INSTANCE_HOME.lower())) +display_name = 'Zope instance at '+INSTANCE_HOME + +# This class exists only so we can take advantage of +# win32serviceutil.HandleCommandLine, it is never +# instantiated. +class InstanceService(service.Service): +_svc_name_ = name +_svc_display_name_ = display_name +_svc_description_ = A Zope application instance running as a service + +# getopt sucks :-( +argv = [sys.argv[0]] +argv.extend(arg.split()) +argv.append(command) + +# we need to supply this manually as HandleCommandLine guesses wrong +serviceClassName = os.path.splitext(service.__file__)[0]+'.Service' + +err = win32serviceutil.HandleCommandLine( +InstanceService, +serviceClassName, +argv=argv, +) + +return err,InstanceService + +return inner + def string_list(arg): return arg.split() @@ -132,11 +167,6 @@ self.python = os.environ.get('PYTHON', config.python) or sys.executable self.zdrun = os.path.join(os.path.dirname(zdaemon.__file__), zdrun.py) -if WIN: -# Add the path to the zopeservice.py script, which is needed for -# some of the Windows specific commands -servicescript = os.path.join(self.directory, 'bin', 'zopeservice.py') -self.servicescript = '%s %s' % (self.python, servicescript) self.exitcodes = [0, 2] if self.logfile is None and config.eventlog is not None: @@ -171,6 +201,8 @@ args = [opt, svalue] return args +## START OF WINDOWS ONLY STUFF + if WIN: def get_status(self): # get_status from zdaemon relies on *nix specific socket handling. @@ -182,46 +214,40 @@ self.zd_status = None return -def do_stop(self, arg): -# Stop the Windows service -program = %s stop % self.options.servicescript -print program -os.system(program) +do_stop = do_windows('stop') +do_restart = do_windows('restart') -def do_restart(self, arg): -# Restart the Windows service -program = %s restart % self.options.servicescript -print program -os.system(program) - # Add extra commands to install and remove the Windows service -def do_install(self, arg): -program = %s install % self.options.servicescript -print program -os.system(program) +def do_install(self,arg): +err,InstanceClass = do_windows('install')(self,arg) +if not err: +# If we installed successfully, put info in registry for the +# real Service class to use: +command = '%s -C %s' % ( +# This gives us the instance script for buildout instances +# and the install script for classic instances. +os.path.join(os.path.split(sys.argv[0])[0],'runzope'), +self.options.configfile +) +InstanceClass.setReg('command',command) def help_install(self): print install -- Installs Zope as a Windows service. -def do_remove(self, arg): -program = %s remove % self.options.servicescript -print program -os.system(program) +do_remove = do_windows('remove') def help_remove(self): print remove -- Removes the Zope Windows service. +## END OF WINDOWS ONLY STUFF + def do_start(self, arg): # signal to Zope that it is
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py make zopectl adduser|run|debug stand a chance of working on Windows.
Log message for revision 104794: make zopectl adduser|run|debug stand a chance of working on Windows. Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 11:34:19 UTC (rev 104793) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 11:44:51 UTC (rev 104794) @@ -253,7 +253,7 @@ def get_startup_cmd(self, python, more): cmdline = ( '%s -c from Zope2 import configure;' -'configure(\'%s\');' % +'configure(%r);' % (python, self.options.configfile) ) return cmdline + more + '\' ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/zopectl.py Make zopectl fg work on Windows by borrowing from plone.recipe.zope2instance
Log message for revision 104795: Make zopectl fg work on Windows by borrowing from plone.recipe.zope2instance Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 11:44:51 UTC (rev 104794) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 11:53:44 UTC (rev 104795) @@ -90,6 +90,17 @@ def string_list(arg): return arg.split() +def quote_command(command): +print .join(command) +# Quote the program name, so it works even if it contains spaces +command = .join(['%s' % x for x in command]) +if WIN: +# odd, but true: the windows cmd processor can't handle more than +# one quoted item per string unless you add quotes around the +# whole line. +command = '%s' % command +return command + class ZopeCtlOptions(ZDOptions): # Zope controller options. # @@ -266,18 +277,19 @@ os.system(cmdline) def do_foreground(self, arg): -if WIN: -# Adding arguments to the program is not supported on Windows -# and the runzope script doesn't put you in debug-mode either -ZDCmd.do_foreground(self, arg) -else: -self.options.program[1:1] = [-X, debug-mode=on] -try: -ZDCmd.do_foreground(self, arg) -finally: -self.options.program.remove(-X) -self.options.program.remove(debug-mode=on) - +program = self.options.program +local_additions = [] +if not program.count('-X'): +local_additions += ['-X'] +if not program.count('debug-mode=on'): +local_additions += ['debug-mode=on'] +program[1:1] = local_additions +command = quote_command(program) +try: +return os.system(command) +finally: +for addition in local_additions: program.remove(addition) + def help_debug(self): print debug -- run the Zope debugger to inspect your database print manually using a Python interactive shell ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/nt_svcutils/service.py Remove pointless call to another function.
Log message for revision 104796: Remove pointless call to another function. Changed: U Zope/branches/2.12/src/nt_svcutils/service.py -=- Modified: Zope/branches/2.12/src/nt_svcutils/service.py === --- Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 11:53:44 UTC (rev 104795) +++ Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 14:09:13 UTC (rev 104796) @@ -112,10 +112,6 @@ # A hook for subclasses to override pass -def createProcess(self, cmd): -self.start_time = time.time() -return self.createProcessCaptureIO(cmd) - def logmsg(self, event): # log a service event using servicemanager.LogMsg try: @@ -305,7 +301,9 @@ self.backoff_interval *= 2 return True -def createProcessCaptureIO(self, cmd): +def createProcess(self, cmd): +self.start_time = time.time() + hInputRead, hInputWriteTemp = self.newPipe() hOutReadTemp, hOutWrite = self.newPipe() pid = win32api.GetCurrentProcess() ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/nt_svcutils/service.py Another big reshuffle of this module, hopefully to make things more readable:
Log message for revision 104814: Another big reshuffle of this module, hopefully to make things more readable: - re-installed some comments that Jeremy obfuscated - renamed the crazily named redirectCaptureThread to a name that matches what it does - highlight the likely cause of #443005: The magic named event is no longer found even though Zope is still running. I suspect this is because runzope is now a setuptools .exe. Changed: U Zope/branches/2.12/src/nt_svcutils/service.py -=- Modified: Zope/branches/2.12/src/nt_svcutils/service.py === --- Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 22:26:47 UTC (rev 104813) +++ Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 22:37:17 UTC (rev 104814) @@ -63,103 +63,24 @@ self._svc_command_ = self.getReg('Command',keyname='PythonClass') win32serviceutil.ServiceFramework.__init__(self, args) + +# Don't use the service name as the event source name: +servicemanager.SetEventSourceName(self.evtlog_name) -servicemanager.SetEventSourceName(self.evtlog_name) # Create an event which we will use to wait on. # The service stop request will set this event. # We create it inheritable so we can pass it to the child process, so # it too can act on the stop event. sa = win32security.SECURITY_ATTRIBUTES() sa.bInheritHandle = True - self.hWaitStop = win32event.CreateEvent(sa, 0, 0, None) -self.redirect_thread = None -@classmethod -def openKey(cls,serviceName,keyname=None): -keypath = System\\CurrentControlSet\\Services\\+serviceName -if keyname: -keypath += ('\\'+keyname) -return win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE,keypath,0,win32con.KEY_ALL_ACCESS) - -@classmethod -def setReg(cls,name,value,serviceName=None,keyname='PythonClass'): -if not serviceName: -serviceName = cls._svc_name_ -key = cls.openKey(serviceName,keyname) -try: -win32api.RegSetValueEx(key, name, 0, win32con.REG_SZ, value) -finally: -win32api.RegCloseKey(key) - -def getReg(self,name,keyname=None): -key = self.openKey(self._svc_name_,keyname) -return win32api.RegQueryValueEx(key,name)[0] - -def SvcStop(self): -# Before we do anything, tell the SCM we are starting the stop process. -self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) -self.onStop() -# Set the stop event - the main loop takes care of termination. -win32event.SetEvent(self.hWaitStop) - -# SvcStop only gets triggered when the user explictly stops (or restarts) -# the service. To shut the service down cleanly when Windows is shutting -# down, we also need to hook SvcShutdown. -SvcShutdown = SvcStop - -def onStop(self): -# A hook for subclasses to override -pass - -def logmsg(self, event): -# log a service event using servicemanager.LogMsg -try: -servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, - event, - (self._svc_name_, -(%s) % self._svc_display_name_)) -except win32api.error, details: -# Failed to write a log entry - most likely problem is -# that the event log is full. We don't want this to kill us -try: -print FAILED to write INFO event, event, :, details -except IOError: -pass - -def _dolog(self, func, msg): -try: -fullmsg = %s (%s): %s % \ - (self._svc_name_, self._svc_display_name_, msg) -func(fullmsg) -except win32api.error, details: -# Failed to write a log entry - most likely problem is -# that the event log is full. We don't want this to kill us -try: -print FAILED to write event log entry:, details -print msg -except IOError: -# And if running as a service, its likely our sys.stdout -# is invalid -pass - -def info(self, s): -self._dolog(servicemanager.LogInfoMsg, s) - -def warning(self, s): -self._dolog(servicemanager.LogWarningMsg, s) - -def error(self, s): -self._dolog(servicemanager.LogErrorMsg, s) - +### ServiceFramework methods + def SvcDoRun(self): # indicate to Zope that the process is daemon managed (restartable) os.environ['ZMANAGED'] = '1' -# XXX the restart behavior is different here than it is for -# zdaemon.zdrun. we should probably do the same thing in both -# places. - # daemon behavior: we want
[Zope-Checkins] SVN: Zope/branches/2.12/src/ - Fix #443005 by using the pid from the pidfile rather than that of runzope.exe
Log message for revision 104815: - Fix #443005 by using the pid from the pidfile rather than that of runzope.exe - correct capitalisation of command reg value name, not that it matters ;-) - add a windebug command to help when debugging windows service behaviour - refactor do_start: nt_svcutils.service.Service sets ZMANAGED, so its not needed on Windows. Changed: U Zope/branches/2.12/src/Zope2/Startup/zopectl.py U Zope/branches/2.12/src/nt_svcutils/service.py -=- Modified: Zope/branches/2.12/src/Zope2/Startup/zopectl.py === --- Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 22:37:17 UTC (rev 104814) +++ Zope/branches/2.12/src/Zope2/Startup/zopectl.py 2009-10-05 23:10:09 UTC (rev 104815) @@ -212,6 +212,11 @@ args = [opt, svalue] return args +def do_start(self, arg): +# signal to Zope that it is being managed +# (to indicate it's web-restartable) +os.putenv('ZMANAGED', '1') + ## START OF WINDOWS ONLY STUFF if WIN: @@ -225,6 +230,7 @@ self.zd_status = None return +do_start = do_windows('start') do_stop = do_windows('stop') do_restart = do_windows('restart') @@ -242,6 +248,11 @@ self.options.configfile ) InstanceClass.setReg('command',command) + +# This is unfortunately needed because runzope.exe is a setuptools +# generated .exe that spawns off a sub process, so pid would give us +# the wrong event name. + InstanceClass.setReg('pid_filename',self.options.configroot.pid_filename) def help_install(self): print install -- Installs Zope as a Windows service. @@ -251,17 +262,13 @@ def help_remove(self): print remove -- Removes the Zope Windows service. +do_windebug = do_windows('debug') + +def help_windebug(self): +print windebug -- Runs the Zope Windows service in the foreground, in debug mode. + ## END OF WINDOWS ONLY STUFF -def do_start(self, arg): -# signal to Zope that it is being managed -# (to indicate it's web-restartable) -os.putenv('ZMANAGED', '1') -if WIN: -do_windows('start')(self,arg) -else: -ZDCmd.do_start(self, arg) - def get_startup_cmd(self, python, more): cmdline = ( '%s -c from Zope2 import configure;' 'configure(%r);' % Modified: Zope/branches/2.12/src/nt_svcutils/service.py === --- Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 22:37:17 UTC (rev 104814) +++ Zope/branches/2.12/src/nt_svcutils/service.py 2009-10-05 23:10:09 UTC (rev 104815) @@ -60,7 +60,7 @@ # ...and from that, we can look up the other needed bits # from the registry: self._svc_display_name_ = self.getReg('DisplayName') -self._svc_command_ = self.getReg('Command',keyname='PythonClass') +self._svc_command_ = self.getReg('command',keyname='PythonClass') win32serviceutil.ServiceFramework.__init__(self, args) @@ -268,26 +268,29 @@ def stop(self,pid): # call the method that any subclasses out there may implement: self.onStop() -# Stop the child process by sending signals to the special named event. - - winver = sys.getwindowsversion() +# This is unfortunately needed because runzope.exe is a setuptools +# generated .exe that spawns off a sub process, so pid would give us +# the wrong event name. +child_pid = int( +open(self.getReg('pid_filename',keyname='PythonClass')).read() +) +# Stop the child process by sending signals to the special named event. for sig, timeout in ( (signal.SIGINT, 30), # We give it 90 seconds to shutdown normally. (signal.SIGTERM, 10) # If that doesn't stop things, we give it 30 # seconds to do a fast shutdown. ): -event_name = Zope-%d-%d % (pid, sig) +# See the Signals.WinSignalHandler module for +# the source of this event name +event_name = Zope-%d-%d % (child_pid,sig) # sys.getwindowsversion() - major, minor, build, platform_id, ver_string # for platform_id, 2==VER_PLATFORM_WIN32_NT if winver[0] = 5 and winver[3] == 2: event_name = Global\\ + event_name try: -# XXX This no longer works, see bug #443005 on Launchpad -# This is likely because cmd in now a setuptools-generated .exe -# Any ideas?
[Zope-Checkins] SVN: Zope/branches/2.12/doc/WINDOWS.rst crufty and outdated.
Log message for revision 104816: crufty and outdated. Changed: D Zope/branches/2.12/doc/WINDOWS.rst -=- Deleted: Zope/branches/2.12/doc/WINDOWS.rst === --- Zope/branches/2.12/doc/WINDOWS.rst 2009-10-05 23:10:09 UTC (rev 104815) +++ Zope/branches/2.12/doc/WINDOWS.rst 2009-10-06 00:05:52 UTC (rev 104816) @@ -1,58 +0,0 @@ -How to build and install Zope from source code on Windows. --- - -* Ensure you have the correct MSVC version installed for the - version of Python you will be using. - -* Install (or build from sources) Python - http://www.python.org - -* Install (or build from sources) the Python for Windows extensions - http://sourceforge.net/projects/pywin32/ - -* Unpack the Zope source distribution. Change to that directory. - -* Execute: - % python.exe inst\configure.py - It should say something like: - - - Zope top-level binary directory will be c:\Zope-2.12. - - Makefile written. - - Next, run the Visual C++ batch file VCVARS32.bat and then nmake. - - (run 'configure.py --help' to see how to change things) - -* 'makefile' will have ben created. As instructed, execute 'nmake'. - If the build succeeds, the last message printed should be: - Zope built. Next, do 'nmake install'. - -* As instructed, execute 'nmake install'. A few warnings will be generated, - but they can be ignored. The last message in the build process should be: - Zope binaries installed successfully. - -* Zope itself has now been installed. We need to create an instance. Run: - % python.exe {install_path}\bin\mkzopeinstance.py - - We will be prompted, via the console, for the instance directory and - username/password for the admin user. - -* We are now ready to start zope. Run: - % {zope_instance}\bin\runzope.bat - Zope should start with nice log messages being printed to - stdout. When Zope is ready, you should see: - -- - 2004-10-13T12:27:58 INFO(0) Zope Ready to handle requests - - Press Ctrl+C to stop this instance of the server. - -* Optionally, install as a Windows service. Execute: - % python {zope_instance}\bin\zopeservice.py - to see the valid options. You may want something like: - % python {zope_instance}\bin\zopeservice.py --startup=auto install - - Once installed, it can be started any number of ways: - - % {zope_instance}\bin\zopectl.bat start - - % python {zope_instance}\bin\zopeservice.py start - - Control Panel - - % net start service_short_name (eg, `net start Zope_-1227678699`) ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/Zope2/Startup/nt/ This appears to be cruft no longer used anywhere...
Log message for revision 104744: This appears to be cruft no longer used anywhere... Changed: D Zope/branches/2.12/src/Zope2/Startup/nt/ -=- ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/src/ Ignore pyd's when they're built in place.
Log message for revision 104688: Ignore pyd's when they're built in place. Changed: _U Zope/branches/2.12/src/AccessControl/ _U Zope/branches/2.12/src/DocumentTemplate/ _U Zope/branches/2.12/src/Missing/ _U Zope/branches/2.12/src/MultiMapping/ _U Zope/branches/2.12/src/Products/ZCTextIndex/ _U Zope/branches/2.12/src/Record/ _U Zope/branches/2.12/src/ThreadLock/ _U Zope/branches/2.12/src/initgroups/ -=- Property changes on: Zope/branches/2.12/src/AccessControl ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/DocumentTemplate ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/Missing ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/MultiMapping ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/Products/ZCTextIndex ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/Record ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/ThreadLock ___ Modified: svn:ignore - *so *.pyc build + *so *.pyc build *.pyd Property changes on: Zope/branches/2.12/src/initgroups ___ Modified: svn:ignore - _initgroups.so + _initgroups.so *.pyd ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/doc/ It's not called Zope 3 anymore and this little stub really doesn't add a lot.
Log message for revision 104691: It's not called Zope 3 anymore and this little stub really doesn't add a lot. Changed: D Zope/branches/2.12/doc/ZOPE3.rst U Zope/branches/2.12/doc/index.rst -=- Deleted: Zope/branches/2.12/doc/ZOPE3.rst === --- Zope/branches/2.12/doc/ZOPE3.rst2009-10-01 18:24:33 UTC (rev 104690) +++ Zope/branches/2.12/doc/ZOPE3.rst2009-10-01 18:29:39 UTC (rev 104691) @@ -1,30 +0,0 @@ -Using Zope Components in Zope 2 Applications - - -Background --- - -Zope 3 is a separate project from the Zope community aimed at web -development. It is designed to be more 'programmer-centric' and easier -to learn, use and extend for programmers. Zope 3 introduces an -interface-centric component architecture that makes it easier to develop -and deploy components without requiring developers to learn and -understand the entire Zope framework. - -As of Zope 2.8, the Five project has been integrated into the -Zope 2 core. The Five project implements a compatibility layer -that allows many Zope 3 components and patterns to be used in -new and existing Zope 2 applications. - -Features - - -The Five integration layer provides support for Zope 3 interfaces, -Zope Configuration Markup Language (ZCML), adapters, views, -utilities and schema-driven content. - -Note that the Five layer does *not* attempt to provide a ZMI user -interface for Zope 3 components. - -Zope 2 includes the essential Zope 3 packages, so it is not -necessary to install Zope 3. Modified: Zope/branches/2.12/doc/index.rst === --- Zope/branches/2.12/doc/index.rst2009-10-01 18:24:33 UTC (rev 104690) +++ Zope/branches/2.12/doc/index.rst2009-10-01 18:29:39 UTC (rev 104691) @@ -11,7 +11,6 @@ CHANGES.rst INSTALL.rst SECURITY.rst - ZOPE3.rst SETUID.rst SIGNALS.rst DEBUGGING.rst ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/doc/ These credits are woefully out of date.
Log message for revision 104692: These credits are woefully out of date. Easier to axe this file than give such a short list compared with the huge number of people who've since contributed. Changed: D Zope/branches/2.12/doc/CREDITS.rst U Zope/branches/2.12/doc/index.rst -=- Deleted: Zope/branches/2.12/doc/CREDITS.rst === --- Zope/branches/2.12/doc/CREDITS.rst 2009-10-01 18:29:39 UTC (rev 104691) +++ Zope/branches/2.12/doc/CREDITS.rst 2009-10-01 18:32:45 UTC (rev 104692) @@ -1,64 +0,0 @@ -Credits -=== - -The Zope software receives contributions from far and wide. Here's -the Zope Hall of Fame: - -- Stephen Purcell allows us to distribute his PyUnit unit testing - framework with Zope. - -- Jeff Bauer is Zope Dude Number One. Jeff took over PCGI and - kept pushing it forward through the years. - -- Sam Rushing worked with us at Digital Creations to make Medusa - the publishing platform for ZServer and the concurrency of Zope2. - -- A subset of windows guru Mark Hammond's win32 extensions are - bundled with win32 binary distributions of Zope. - -- Martijn Pieters and Brian Hooper contributed the #in reverse - attribute. - -- Phillip Eby contributed the DTML 'let' tag and many - other useful ideas, including the inspiration for the DTML - 'call', 'with' and 'return' - tags. - -- The DateTime module was based on work from Ted Horst. - -- Jordan Baker contributed the 'try' tag, something we've wanted - for a long, long time. - -- Martijn Pieters chipped in with a safe range function. - -- Michael Hauser came up with the name Zope. - -- Eric Kidd from Userland contributed to ZPublisher's support for - XML-RPC. - -- Andrew M. Kuchling wrote the initial version of mod_pcgi, making - him extremely cool in our book. - -- Oleg Broytmann has taken up the standard of mod_pcgi and moving - it to be a really amazing thing, and ready for prime time. - -- Jephte CLAIN made some patches to European ZopeTime. - -- Thanks to Gregor Hoffleit for his work in getting Zope into the - Debian distribution. - -- All the other Zopistas far and wide that stuck with us during - the Bobo/Principia days and politely push us to make the best damn - app server on this or any other planet. - -- Of course the list of credits would be quite incomplete without - mentioning Guido van Rossum, benevolent dictator of Python and - long-time friend of Digital Creations. Zope Power is Python - Power. - -- Special thanks to Richard Stallman and the Free Software - Foundation for their assistance and feedback on the - GPL-compatible 2.0 version of the Zope Public License. - - - Modified: Zope/branches/2.12/doc/index.rst === --- Zope/branches/2.12/doc/index.rst2009-10-01 18:29:39 UTC (rev 104691) +++ Zope/branches/2.12/doc/index.rst2009-10-01 18:32:45 UTC (rev 104692) @@ -14,5 +14,4 @@ SETUID.rst SIGNALS.rst DEBUGGING.rst - CREDITS.rst ___ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.12/doc/ Split, tidy and update docs to do with special users and filesystem permissions.
Log message for revision 104694: Split, tidy and update docs to do with special users and filesystem permissions. Changed: U Zope/branches/2.12/doc/SECURITY.rst A Zope/branches/2.12/doc/USERS.rst U Zope/branches/2.12/doc/index.rst -=- Modified: Zope/branches/2.12/doc/SECURITY.rst === --- Zope/branches/2.12/doc/SECURITY.rst 2009-10-01 18:35:28 UTC (rev 104693) +++ Zope/branches/2.12/doc/SECURITY.rst 2009-10-01 18:47:11 UTC (rev 104694) @@ -1,87 +1,18 @@ -Setting the initial user name and password -== +Filesytem Permissions += -Because Zope is managed through the web, user names and passwords must be -used to assure that only authorized people can make changes to a Zope -installation. - -Some user name and password is needed to bootstrap the creation of -normal managers of your Zope site. This is accomplished through the -use of the file 'inituser'. The first time Zope starts, it will detect -that no users have been defined in the root user folder. It will search -for the 'inituser' file and, if it exists, will add the user defined -in the file to the root user folder. - -Normally, 'inituser' is created by the Zope install scripts. Either -the installer prompts for the password or a randomly generated -password is created and displayed at the end of the build script. - -You can use the 'zpasswd.py' script to create 'inituser' yourself. -Execute 'zpasswd.py' like this:: - -python zpasswd.py inituser - -The script will prompt you for the name, password, and allowed -domains. The default is to encode the password with SHA, so please -remember this password as there is no way to recover it (although -'zpasswd.py' lets you reset it.) - -In some situations you may need to bypass normal security controls -because you have lost your password or because the security settings -have been mixed up. Zope provides a facility called an emergency -user so that you can reset passwords and correct security -settings. - -The emergency user password must be defined outside the application -user interface. It is defined in the 'access' file located -in the Zope directory. It should be readable only by the user -as which your web server runs. - -To create the emergency user, use 'zpasswd.py' to create the -'access' file like this:: - -python zpasswd.py access - -In order to provide a somewhat higher level of security, various -encoding schemes are supported which provide access to either SHA-1 -encryption or the standard UNIX crypt facility if it has been compiled -into Python. Unless you have some special requirements (see below), -you should use the SHA-1 facility, which is the default. - -Format of 'inituser' and 'access' -- - -A password file should consist of a single line of the form:: - -name:password - -Note that you may also add an optional third component to the line in the -access file to restrict access by domain. For example, the line:: - -mario:nintendoRules:*.mydomain.com - -in your 'access' file will only allow permit emergency user access -from `*.mydomain.com` machines. Attempts to access the system from -other domains will fail, even if the correct emergency user name -and password are used. - -Please note that if you use the ZServer monitor capability, you will -need to run with a clear text password. - -Setting permissions on the var directory - - -You need to set permissions on the Zope var directory. -Zope needs to read and write data from its var directory. Before +You need to set permissions on the directory Zope uses to store its +data. This will normally be the `var` directory in the instance home. +Zope needs to read and write data to this directory. Before running Zope you should ensure that you give adequate permissions -to the Zope var directory for the userid Zope will run under. +to this directory for the userid Zope will run under. Depending on how you choose to run Zope you will need to give -different permissions to the var directory. If you use Zope with an +different permissions to the directory. If you use Zope with an existing web server, it will probably run Zope as 'nobody'. In this case 'nobody' needs read and write permissions to the var directory. -If you change the way you run Zope you may need to modify the permissions -of the var directory and the files in it to allow Zope to read and write +If you change the way you run Zope, you may need to modify the permissions +of the directory and the files in it to allow Zope to read and write under its changed userid. Copied: Zope/branches/2.12/doc/USERS.rst (from rev 104684, Zope/branches/2.12/doc/SECURITY.rst) === --- Zope/branches/2.12/doc/USERS.rst(rev 0) +++ Zope/branches/2.12/doc/USERS.rst
[Zope-Checkins] SVN: Zope/trunk/ Revert changes made in the name of #375322.
Log message for revision 99869: Revert changes made in the name of #375322. These changes weren't discussed with the community first, they break backwards compatibility, and environment should logically be one dict-like object, not a sequence of dicts. Changed: U Zope/trunk/doc/CHANGES.rst U Zope/trunk/src/Zope2/Startup/handlers.py U Zope/trunk/src/Zope2/Startup/tests/test_schema.py U Zope/trunk/src/Zope2/Startup/zopeschema.xml -=- Modified: Zope/trunk/doc/CHANGES.rst === --- Zope/trunk/doc/CHANGES.rst 2009-05-12 09:57:03 UTC (rev 99868) +++ Zope/trunk/doc/CHANGES.rst 2009-05-12 10:50:04 UTC (rev 99869) @@ -14,10 +14,6 @@ - zExceptions.convertExceptionType: new API, breaking out conversion of exception names to exception types from 'upgradeException'. -- Launchpad #375322: the environment section within the zope.conf - file is now a multisection in order to provide a more modular configuration - support. - - Launchpad #374719: introducing new ZPublisher events: PubStart, PubSuccess, PubFailure, PubAfterTraversal and PubBeforeCommit. Modified: Zope/trunk/src/Zope2/Startup/handlers.py === --- Zope/trunk/src/Zope2/Startup/handlers.py2009-05-12 09:57:03 UTC (rev 99868) +++ Zope/trunk/src/Zope2/Startup/handlers.py2009-05-12 10:50:04 UTC (rev 99869) @@ -184,10 +184,8 @@ # Set environment variables -d = {} -for s in config.environment: -d.update(s) -os.environ.update(d) +for k,v in config.environment.items(): +os.environ[k] = v # Add directories to the pythonpath instancelib = os.path.join(config.instancehome, 'lib', 'python') Modified: Zope/trunk/src/Zope2/Startup/tests/test_schema.py === --- Zope/trunk/src/Zope2/Startup/tests/test_schema.py 2009-05-12 09:57:03 UTC (rev 99868) +++ Zope/trunk/src/Zope2/Startup/tests/test_schema.py 2009-05-12 10:50:04 UTC (rev 99869) @@ -101,23 +101,9 @@ NSYNC doesnt /environment ) -items = conf.environment[0].items() +items = conf.environment.items() items.sort() self.assertEqual(items, [(FEARFACTORY, rocks), (NSYNC,doesnt)]) -conf, handler = self.load_config_text(\ -# instancehome is here since it's required -instancehome INSTANCE_HOME -environment - FEARFACTORY rocks -/environment -environment - NSYNC doesnt -/environment -) -self.assertEqual(len(conf.environment), 2) -# in principle, we should test the handler as well -# But this would have vast side effects -# Thus, we test with a non regression test def test_ms_author_via(self): import webdav Modified: Zope/trunk/src/Zope2/Startup/zopeschema.xml === --- Zope/trunk/src/Zope2/Startup/zopeschema.xml 2009-05-12 09:57:03 UTC (rev 99868) +++ Zope/trunk/src/Zope2/Startup/zopeschema.xml 2009-05-12 10:50:04 UTC (rev 99869) @@ -292,14 +292,14 @@ /description /multisection - multisection type=environment attribute=environment name=* + section type=environment attribute=environment name=* description A section which allows a user to define arbitrary key-value pairs for use as environment variables during Zope's run cycle. It is not recommended to set system-related environment variables such as PYTHONPATH within this section. /description - /multisection + /section key name=instancehome datatype=existing-directory required=yes ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/setup.py bump version number
Log message for revision 99205: bump version number Changed: U Zope/trunk/setup.py -=- Modified: Zope/trunk/setup.py === --- Zope/trunk/setup.py 2009-04-15 20:17:52 UTC (rev 99204) +++ Zope/trunk/setup.py 2009-04-15 22:03:29 UTC (rev 99205) @@ -19,7 +19,7 @@ EXTENSIONCLASS_INCLUDEDIRS = ['include', 'src'] params = dict(name='Zope2', -version='2.12.0.a1', +version='2.12.0.a2dev', url='http://www.zope.org', license='ZPL 2.1', description='Zope2 application server / web framework', ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py de-convolute-ize zopectl run and make providing the correct sys.argv to the run script more robust.
Log message for revision 99160: de-convolute-ize zopectl run and make providing the correct sys.argv to the run script more robust. Changed: U Zope/trunk/src/Zope2/Startup/zopectl.py -=- Modified: Zope/trunk/src/Zope2/Startup/zopectl.py === --- Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-13 19:36:57 UTC (rev 99159) +++ Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-13 20:58:49 UTC (rev 99160) @@ -256,18 +256,16 @@ print debug -- run the Zope debugger to inspect your database print manually using a Python interactive shell -def do_run(self, arg): -tup = arg.split(' ') -if not arg: +def do_run(self, args): +if not args: print usage: run script [args] return -# remove -c and add script as sys.argv[0] -script = tup[0] -cmd = 'import sys; sys.argv.pop(); sys.argv.append(\'%s\');' % script -if len(tup) 1: -argv = tup[1:] -cmd += '[sys.argv.append(x) for x in %s];' % argv -cmd += 'import Zope2; app=Zope2.app(); execfile(\'%s\')' % script +# replace sys.argv +script = args.split(' ')[0] +cmd = ( +import sys; sys.argv[:]=%r.split(' '); +import Zope2; app=Zope2.app(); execfile(%r) +) % (args,script) cmdline = self.get_startup_cmd(self.options.python, cmd) self._exitstatus = os.system(cmdline) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/versions-zope3.cfg Use the latests zdaemon to zopectl -h and runzope -h work again :-)
Log message for revision 99136: Use the latests zdaemon to zopectl -h and runzope -h work again :-) Changed: U Zope/trunk/versions-zope3.cfg -=- Modified: Zope/trunk/versions-zope3.cfg === --- Zope/trunk/versions-zope3.cfg 2009-04-12 03:20:35 UTC (rev 99135) +++ Zope/trunk/versions-zope3.cfg 2009-04-12 10:38:01 UTC (rev 99136) @@ -54,7 +54,7 @@ zc.resourcelibrary = 1.0.2 zc.table = 0.7.0 zc.zope3recipes = 0.7.0 -zdaemon = 2.0.2 +zdaemon = 2.0.3 zodbcode = 3.4.0 zope.annotation = 3.4.1 zope.app.apidoc = 3.6.1 ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: zdaemon/trunk/ preparing for 2.0.3 release
Log message for revision 99132: preparing for 2.0.3 release Changed: U zdaemon/trunk/CHANGES.txt U zdaemon/trunk/setup.py U zdaemon/trunk/src/zdaemon/zdctl.py -=- Modified: zdaemon/trunk/CHANGES.txt === --- zdaemon/trunk/CHANGES.txt 2009-04-11 16:11:02 UTC (rev 99131) +++ zdaemon/trunk/CHANGES.txt 2009-04-11 17:45:50 UTC (rev 99132) @@ -1,7 +1,7 @@ zdaemon Changelog * -zdaemon 2.0.3 (unreleased) +zdaemon 2.0.3 (2009/04/11) == - Added support to bootstrap on Jython. @@ -16,6 +16,9 @@ This lets you run the tests on Python 2.4 and 2.5 simultaneously without spurious errors. +- make -h work again for both runner and control scripts. + Help is now taken from the __doc__ of the options class users by + the zdaemon script being run. zdaemon 2.0.2 (2008/04/05) == Modified: zdaemon/trunk/setup.py === --- zdaemon/trunk/setup.py 2009-04-11 16:11:02 UTC (rev 99131) +++ zdaemon/trunk/setup.py 2009-04-11 17:45:50 UTC (rev 99132) @@ -37,7 +37,7 @@ name = zdaemon setup( name=name, -version=2.0.3dev, +version=2.0.3, url=http://www.python.org/pypi/zdaemon;, license=ZPL 2.1, description= Modified: zdaemon/trunk/src/zdaemon/zdctl.py === --- zdaemon/trunk/src/zdaemon/zdctl.py 2009-04-11 16:11:02 UTC (rev 99131) +++ zdaemon/trunk/src/zdaemon/zdctl.py 2009-04-11 17:45:50 UTC (rev 99132) @@ -16,7 +16,7 @@ Usage: python zdctl.py [-C URL] [-S schema.xml] [-h] [-p PROGRAM] [zdrun-options] [action [arguments]] - + Options: -C/--configure URL -- configuration file or URL -S/--schema XML Schema -- XML schema for configuration file ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: zdaemon/tags/2.0.3/ tagging 2.0.3
Log message for revision 99133: tagging 2.0.3 Changed: A zdaemon/tags/2.0.3/ -=- ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zope add python option to zope.conf schema allowing for a python binary to be specified, allowed a Zope instance to run from any buildout with the a
Log message for revision 99134: add python option to zope.conf schema allowing for a python binary to be specified, allowed a Zope instance to run from any buildout with the appropriate eggs. Changed: U Zope/trunk/src/Zope2/Startup/zopectl.py U Zope/trunk/src/Zope2/Startup/zopeschema.xml -=- Modified: Zope/trunk/src/Zope2/Startup/zopectl.py === --- Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-11 17:48:10 UTC (rev 99133) +++ Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-11 17:52:25 UTC (rev 99134) @@ -129,7 +129,7 @@ self.sockname = config.runner.socket_name else: self.sockname = os.path.join(self.clienthome, zopectlsock) -self.python = sys.executable +self.python = config.python or sys.executable self.zdrun = os.path.join(os.path.dirname(zdaemon.__file__), zdrun.py) if WIN: Modified: Zope/trunk/src/Zope2/Startup/zopeschema.xml === --- Zope/trunk/src/Zope2/Startup/zopeschema.xml 2009-04-11 17:48:10 UTC (rev 99133) +++ Zope/trunk/src/Zope2/Startup/zopeschema.xml 2009-04-11 17:52:25 UTC (rev 99134) @@ -945,4 +945,14 @@ /description /multisection +key name=python datatype=existing-path + required=no + description +Path to the Python interpreter for use by zdaemon. +Defaults to sys.executable. +Needed for buildout-based instances to supply a python +that has all the correct eggs on the path. + /description +/key + /schema ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: zdaemon/trunk/src/zdaemon/ Provide doc strings for these two base classes.
Log message for revision 99071: Provide doc strings for these two base classes. Changed: U zdaemon/trunk/src/zdaemon/tests/testzdoptions.py U zdaemon/trunk/src/zdaemon/zdoptions.py -=- Modified: zdaemon/trunk/src/zdaemon/tests/testzdoptions.py === --- zdaemon/trunk/src/zdaemon/tests/testzdoptions.py2009-04-10 09:35:06 UTC (rev 99070) +++ zdaemon/trunk/src/zdaemon/tests/testzdoptions.py2009-04-10 09:50:13 UTC (rev 99071) @@ -104,9 +104,17 @@ self.assertEqual(helptext, expected) def test_default_help(self): +# test what happens if OptionsClass is used directly. +# Not sure this ever happens :-S +self.help_test_helper(self.OptionsClass,{},self.OptionsClass.__doc__ or 'No help available.') + +def test_default_subclass_help(self): # test what happens when the subclass doesn't do anything # with __doc__ -self.help_test_helper(self.OptionsClass,{},'No help available.') +class SubClass(self.OptionsClass): +pass +# __doc__ isn't inherited :-( +self.help_test_helper(SubClass,{},'No help available.') def test_default_help_with_doc_kw(self): # test what happens when the subclass doesn't do anything Modified: zdaemon/trunk/src/zdaemon/zdoptions.py === --- zdaemon/trunk/src/zdaemon/zdoptions.py 2009-04-10 09:35:06 UTC (rev 99070) +++ zdaemon/trunk/src/zdaemon/zdoptions.py 2009-04-10 09:50:13 UTC (rev 99071) @@ -21,7 +21,21 @@ import ZConfig class ZDOptions: +a zdaemon script. +Usage: python script.py [-C URL] [zdrun-options] [action [arguments]] + +Options: +-C/--configure URL -- configuration file or URL +-h/--help -- print usage message and exit + +Actions are commands like start, stop and status. If -i is +specified or no action is specified on the command line, a shell +interpreting actions typed interactively is started (unless the +configuration option default_to_interactive is set to false). Use the +action help to find out about available actions. + + doc = None progname = None configfile = None @@ -341,7 +355,31 @@ class RunnerOptions(ZDOptions): +a zdaemon runner. +Usage: python script.py [-C URL][-h] [zdrun-options] [action [arguments]] + +Options: +-C/--configure URL -- configuration file or URL +-h/--help -- print usage message and exit +-b/--backoff-limit SECONDS -- set backoff limit to SECONDS (default 10) +-d/--daemon -- run as a proper daemon; fork a subprocess, close files etc. +-f/--forever -- run forever (by default, exit when backoff limit is exceeded) +-h/--help -- print this usage message and exit +-s/--socket-name SOCKET -- Unix socket name for client (default zdsock) +-u/--user USER -- run as this user (or numeric uid) +-m/--umask UMASK -- use this umask for daemon subprocess (default is 022) +-x/--exit-codes LIST -- list of fatal exit codes (default 0,2) +-z/--directory DIRECTORY -- directory to chdir to when using -d (default off) +action [arguments] -- see below + +Actions are commands like start, stop and status. If -i is +specified or no action is specified on the command line, a shell +interpreting actions typed interactively is started (unless the +configuration option default_to_interactive is set to false). Use the +action help to find out about available actions. + + uid = gid = None def __init__(self): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/ make runzope -h work onc the new zdaemon release is used.
Log message for revision 99072: make runzope -h work onc the new zdaemon release is used. Changed: U Zope/trunk/src/Zope2/Startup/options.py U Zope/trunk/src/Zope2/Startup/run.py -=- Modified: Zope/trunk/src/Zope2/Startup/options.py === --- Zope/trunk/src/Zope2/Startup/options.py 2009-04-10 09:50:13 UTC (rev 99071) +++ Zope/trunk/src/Zope2/Startup/options.py 2009-04-10 10:02:10 UTC (rev 99072) @@ -20,7 +20,30 @@ class ZopeOptions(zdaemon.zdoptions.ZDOptions): +The Zope zdaemon runner script. +Usage: python Zope2/run.py [-C URL][-h] [zdrun-options] [action [arguments]] + +Options: +-C/--configure URL -- configuration file or URL +-h/--help -- print usage message and exit +-b/--backoff-limit SECONDS -- set backoff limit to SECONDS (default 10) +-d/--daemon -- run as a proper daemon; fork a subprocess, close files etc. +-f/--forever -- run forever (by default, exit when backoff limit is exceeded) +-h/--help -- print this usage message and exit +-s/--socket-name SOCKET -- Unix socket name for client (default zdsock) +-u/--user USER -- run as this user (or numeric uid) +-m/--umask UMASK -- use this umask for daemon subprocess (default is 022) +-x/--exit-codes LIST -- list of fatal exit codes (default 0,2) +-z/--directory DIRECTORY -- directory to chdir to when using -d (default off) +action [arguments] -- see below + +Actions are commands like start, stop and status. If -i is +specified or no action is specified on the command line, a shell +interpreting actions typed interactively is started (unless the +configuration option default_to_interactive is set to false). Use the +action help to find out about available actions. + + schemadir = os.path.dirname(os.path.abspath(__file__)) schemafile = zopeschema.xml - Modified: Zope/trunk/src/Zope2/Startup/run.py === --- Zope/trunk/src/Zope2/Startup/run.py 2009-04-10 09:50:13 UTC (rev 99071) +++ Zope/trunk/src/Zope2/Startup/run.py 2009-04-10 10:02:10 UTC (rev 99072) @@ -43,9 +43,9 @@ opts = options.ZopeOptions() if configfile: opts.configfile = configfile -opts.realize(doc=Sorry, no option docs yet., raise_getopt_errs=0) +opts.realize(raise_getopt_errs=0) else: -opts.realize(doc=Sorry, no option docs yet.) +opts.realize() handlers.handleConfig(opts.configroot, opts.confighandlers) import App.config ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: zdaemon/trunk/setup.py remove development status trove category
Log message for revision 99050: remove development status trove category Changed: U zdaemon/trunk/setup.py -=- Modified: zdaemon/trunk/setup.py === --- zdaemon/trunk/setup.py 2009-04-09 16:35:15 UTC (rev 99049) +++ zdaemon/trunk/setup.py 2009-04-09 16:44:56 UTC (rev 99050) @@ -61,7 +61,6 @@ packages=[zdaemon, zdaemon.tests], package_dir={: src}, classifiers = [ - 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: Zope Public License', ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: zdaemon/trunk/src/zdaemon/tests/testzdrun.py these tests have been commented out for 5 years, I think it's safe to say they can go.
Log message for revision 99063: these tests have been commented out for 5 years, I think it's safe to say they can go. Changed: U zdaemon/trunk/src/zdaemon/tests/testzdrun.py -=- Modified: zdaemon/trunk/src/zdaemon/tests/testzdrun.py === --- zdaemon/trunk/src/zdaemon/tests/testzdrun.py2009-04-09 21:56:51 UTC (rev 99062) +++ zdaemon/trunk/src/zdaemon/tests/testzdrun.py2009-04-09 22:03:10 UTC (rev 99063) @@ -110,26 +110,6 @@ self.rundaemon([echo, -n]) self.expect = -## def testInvoke(self): -## self._run(echo -n) -## self.expect = - -## def testControl(self): -## self.rundaemon([sleep, 1000]) -## time.sleep(1) -## self._run(stop) -## time.sleep(1) -## self._run(exit) -## self.expect = Sent SIGTERM\nExiting now\n - -## def testStop(self): -## self.rundaemon([self.python, self.nokill]) -## time.sleep(1) -## self._run(stop) -## time.sleep(1) -## self._run(exit) -## self.expect = Sent SIGTERM\nSent SIGTERM; will exit later\n - def testHelp(self): # XXX We shouldn't mutate and leave our change in! import __main__ ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: zdaemon/trunk/src/zdaemon/ Sort out where help docs come from.
Log message for revision 99067: Sort out where help docs come from. The original intent was that the __doc__ of the __main__ module was used in no overridden by passing doc as a keyword argument to realize. However, as buildout generates scripts, the __doc__ of __main__ will always be blank. So, changed the mechanism to use __doc__ of the options class and set the __doc__ of all the options classes to the __doc__ of their containing module, giving the original intended effect. Changed: U zdaemon/trunk/src/zdaemon/tests/testzdoptions.py U zdaemon/trunk/src/zdaemon/tests/testzdrun.py U zdaemon/trunk/src/zdaemon/zdctl.py U zdaemon/trunk/src/zdaemon/zdoptions.py U zdaemon/trunk/src/zdaemon/zdrun.py -=- Modified: zdaemon/trunk/src/zdaemon/tests/testzdoptions.py === --- zdaemon/trunk/src/zdaemon/tests/testzdoptions.py2009-04-09 22:36:51 UTC (rev 99066) +++ zdaemon/trunk/src/zdaemon/tests/testzdoptions.py2009-04-10 00:30:16 UTC (rev 99067) @@ -81,58 +81,64 @@ options.realize([arg, configfile]) self.assertEqual(options.configfile, configfile) -def test_help(self): -# __main__.__doc__ is used as the default source of the help -# text; specific text can also be provided in the `doc` -# keyword arg to `realize()`. -import __main__ -old_doc = __main__.__doc__ -__main__.__doc__ = Example help text 1. -try: -for arg in -h, --h, --help: -for doc in (None, Example help text 2.): -options = self.OptionsClass() -try: -self.save_streams() -try: -if doc: -options.realize([arg], doc=doc) -else: -options.realize([arg]) -finally: -self.restore_streams() -except SystemExit, err: -self.assertEqual(err.code, 0) -else: -self.fail(%s didn't call sys.exit() % repr(arg)) -helptext = self.stdout.getvalue() -self.assertEqual(helptext, doc or __main__.__doc__) -finally: -__main__.__doc__ = old_doc +# The original intent was that the docstring of whatever module is +# __main__ would be used as help documentation. +# Because of the way buildout generates scripts, this will always +# be an empty string. +# So, we now use the __doc__ of the options class being used. -def test_no_help(self): -# Test that zdoptions doesn't die when __main__.__doc__ is None. -import __main__ -old_doc = __main__.__doc__ -__main__.__doc__ = None -try: -for arg in -h, --h, --help: -options = self.OptionsClass() +def help_test_helper(self,optionsclass,kw,expected): +for arg in -h, --h, --help: +options = optionsclass() +try: +self.save_streams() try: -self.save_streams() -try: -options.realize([arg]) -finally: -self.restore_streams() -except SystemExit, err: -self.assertEqual(err.code, 0) -else: -self.fail(%s didn't call sys.exit() % repr(arg)) -helptext = self.stdout.getvalue() -self.assertEqual(helptext, No help available.) -finally: -__main__.__doc__ = old_doc +options.realize([arg],**kw) +finally: +self.restore_streams() +except SystemExit, err: +self.assertEqual(err.code, 0) +else: +self.fail(%s didn't call sys.exit() % repr(arg)) +helptext = self.stdout.getvalue() +self.assertEqual(helptext, expected) + +def test_default_help(self): +# test what happens when the subclass doesn't do anything +# with __doc__ +self.help_test_helper(self.OptionsClass,{},'No help available.') +def test_default_help_with_doc_kw(self): +# test what happens when the subclass doesn't do anything +# with __doc__, but doc is supplied to realize +self.help_test_helper(self.OptionsClass,{'doc':'Example help'},'Example help') + +def test_no_help(self): +# test what happens when the subclass has None for __doc__ +class NoHelp(self.OptionsClass): +__doc__ = None +self.help_test_helper(NoHelp,{},'No help available.') + +def test_no_help_with_doc_kw(self): +# test what happens when the subclass has None for __doc__, +#
[Zope-Checkins] SVN: Zope/trunk/src/Zope2/Startup/zopectl.py make zopectl -h work once the new zdaemon release is used.
Log message for revision 99068: make zopectl -h work once the new zdaemon release is used. Changed: U Zope/trunk/src/Zope2/Startup/zopectl.py -=- Modified: Zope/trunk/src/Zope2/Startup/zopectl.py === --- Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-10 00:30:16 UTC (rev 99067) +++ Zope/trunk/src/Zope2/Startup/zopectl.py 2009-04-10 01:00:10 UTC (rev 99068) @@ -56,12 +56,14 @@ return arg.split() class ZopeCtlOptions(ZDOptions): -Zope controller options. +# Zope controller options. +# +# After initialization, this should look very much like a +# zdaemon.zdctl.ZDCtlOptions instance. Many of the attributes are +# initialized from different sources, however. -After initialization, this should look very much like a -zdaemon.zdctl.ZDCtlOptions instance. Many of the attributes are -initialized from different sources, however. - +__doc__ = __doc__ + positional_args_allowed = 1 program = zopectl @@ -73,7 +75,7 @@ # same logging for zdctl as for the Zope appserver. There still # needs to be a way to set a logfile for zdctl. logsectionname = None - + def __init__(self): ZDOptions.__init__(self) self.add(program, runner.program, p:, program=, ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/skel/etc/zope.conf.in Note on full mount point syntax.
Log message for revision 85144: Note on full mount point syntax. Changed: U Zope/trunk/skel/etc/zope.conf.in -=- Modified: Zope/trunk/skel/etc/zope.conf.in === --- Zope/trunk/skel/etc/zope.conf.in2008-04-07 06:55:17 UTC (rev 85143) +++ Zope/trunk/skel/etc/zope.conf.in2008-04-07 10:12:10 UTC (rev 85144) @@ -1061,6 +1061,13 @@ # ZEO client storage: # # zodb_db main +# # The full mount-point syntax is: +# # +# # mount-point localpath[:remotepath] +# # +# # localpath - the path where the storage is mounted in this instance +# # remotepath - is the path to the object in the storage where it is mounted +# # from. This defaults to whatever is supplied for localpath. # mount-point / # # ZODB cache, in number of objects # cache-size 5000 ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] SVN: Zope/branches/2.10/ Backported discouraged warning for manage_* events from trunk
Hanno Schlichting wrote: Log message for revision 81167: Backported discouraged warning for manage_* events from trunk If this stuff isn't going away, warnings shouldn't be omitted at all, regardless of the wording... If these methods are staying around, by all means put comments in the code about what it stylistically correct, but actually issuing a warning, regardless of the wording, means something *needs* to be changed which simply isn't the case here... Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] SVN: Zope/trunk/ Made Helpsys.HelpSys internal ZCatalog creation lazy, so it isn't created unless first accessed.
Hanno Schlichting wrote: Log message for revision 81408: Made Helpsys.HelpSys internal ZCatalog creation lazy, so it isn't created unless first accessed. This seems a little pointless as either: - the catalog will get created as soon as any help is indexed, which will be always - the first time you access the help system, you'll have to wait while all the help is indexed Neither are great. Have you tested that this change actually makes a difference? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] SVN: Zope/trunk/ support for a configurable resolver for UnicodeDecodeErrors
I must have missed it, but where are your tests for this and the other unicode changes? Andreas Jung wrote: Log message for revision 71753: support for a configurable resolver for UnicodeDecodeErrors Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/Products/PageTemplates/Expressions.py A Zope/trunk/lib/python/Products/PageTemplates/configure.zcml A Zope/trunk/lib/python/Products/PageTemplates/interfaces.py A Zope/trunk/lib/python/Products/PageTemplates/unicodeconflictresolver.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2007-01-07 10:25:20 UTC (rev 71752) +++ Zope/trunk/doc/CHANGES.txt 2007-01-07 10:32:39 UTC (rev 71753) @@ -48,6 +48,10 @@ 'output_encodings' property that controls the conversion from/to unicode for WebDAV/FTP operations. + - the ZPT implementation has now a configurable option in order how to deal +with UnicodeDecodeErrors. A custom UnicodeEncodingConflictResolver can +be configured through ZCML (see Products/PageTemplates/(configure.zcml, +unicodeconflictresolver.py, interfaces.py) Bugs Fixed Modified: Zope/trunk/lib/python/Products/PageTemplates/Expressions.py === --- Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2007-01-07 10:25:20 UTC (rev 71752) +++ Zope/trunk/lib/python/Products/PageTemplates/Expressions.py 2007-01-07 10:32:39 UTC (rev 71753) @@ -17,6 +17,10 @@ $Id$ + +import logging + +from zope.component import getUtility from zope.interface import implements from zope.tales.tales import Context, Iterator from zope.tales.expressions import PathExpr, StringExpr, NotExpr @@ -31,13 +35,17 @@ from MultiMapping import MultiMapping from Acquisition import aq_base from zExceptions import NotFound, Unauthorized + from Products.Five.browser.providerexpression import Z2ProviderExpression from Products.PageTemplates import ZRPythonExpr from Products.PageTemplates.DeferExpr import LazyExpr from Products.PageTemplates.GlobalTranslationService import getGlobalTranslationService +from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver SecureModuleImporter = ZRPythonExpr._SecureModuleImporter() +LOG = logging.getLogger('Expressions') + # BBB 2005/05/01 -- remove after 12 months import zope.deprecation from zope.deprecation import deprecate @@ -173,6 +181,44 @@ domain, msgid, mapping=mapping, context=context, default=default) + +def evaluateText(self, expr): + customized version in order to get rid of unicode +errors for all and ever + + +text = self.evaluate(expr) + +if text is self.getDefault() or text is None: +# XXX: should be unicode??? +return text + +if isinstance(text, unicode): +# we love unicode, nothing to do +return text + +elif isinstance(text, str): +# bahh...non-unicode string..we need to convert it to unicode +resolver = getUtility(IUnicodeEncodingConflictResolver) + +try: +return resolver.resolve(self.contexts['context'], text, expr) +except UnicodeDecodeError,e: +LOG.error(UnicodeDecodeError detected for expression %s\n + Resolver class: %s\n + Exception text: %s\n + Template: %s\n + Rendered text: %r % \ + (expr, resolver.__class__, e, +self.contexts['template'].absolute_url(1), text)) +raise +else: + +# This is a weird culprit ...calling unicode() on non-string +# objects +return unicode(text) + + class ZopeEngine(zope.app.pagetemplate.engine.ZopeEngine): _create_context = ZopeContext Copied: Zope/trunk/lib/python/Products/PageTemplates/configure.zcml (from rev 71752, Zope/branches/ajung-death-to-unicode-errors/lib/python/Products/PageTemplates/configure.zcml) Copied: Zope/trunk/lib/python/Products/PageTemplates/interfaces.py (from rev 71752, Zope/branches/ajung-death-to-unicode-errors/lib/python/Products/PageTemplates/interfaces.py) Copied: Zope/trunk/lib/python/Products/PageTemplates/unicodeconflictresolver.py (from rev 71752, Zope/branches/ajung-death-to-unicode-errors/lib/python/Products/PageTemplates/unicodeconflictresolver.py) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Checkins maillist - Zope-Checkins@zope.org
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/ - replace nasty and ineffective hack for dynamic connections ids in ZSQL Method cache which is tested and works
Log message for revision 71151: - replace nasty and ineffective hack for dynamic connections ids in ZSQL Method cache which is tested and works - simplify tests as a result - make sure full chain of DA.__call__ and DA._cached_result is execercised Changed: U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py -=- Modified: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py === --- Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 12:30:35 UTC (rev 71150) +++ Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 13:22:41 UTC (rev 71151) @@ -352,11 +352,8 @@ def _searchable_result_columns(self): return self._col -def _cached_result(self, DB__, query): -pure_query = query -# we need to munge the incoming query key in the cache -# so that the same request to a different db is returned -query = query + ('\nDBConnId: %s' % self.connection_hook, ) +def _cached_result(self, DB__, query, max_rows, conn_id): +cache_key = query,max_rows,conn_id # Try to fetch from cache if hasattr(self,'_v_cache'): cache=self._v_cache @@ -376,15 +373,15 @@ del cache[q] del keys[-1] -if cache.has_key(query): -k, r = cache[query] +if cache.has_key(cache_key): +k, r = cache[cache_key] if k t: return r # call the pure query -result=apply(DB__.query, pure_query) +result=DB__.query(query,max_rows) if self.cache_time_ 0: -tcache[int(now)]=query -cache[query]= now, result +tcache[int(now)]=cache_key +cache[cache_key]= now, result return result @@ -450,8 +447,9 @@ if src__: return query if self.cache_time_ 0 and self.max_cache_ 0: -result=self._cached_result(DB__, (query, self.max_rows_)) -else: result=DB__.query(query, self.max_rows_) +result=self._cached_result(DB__, query, self.max_rows_, c) +else: +result=DB__.query(query, self.max_rows_) if hasattr(self, '_v_brain'): brain=self._v_brain else: Modified: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py === --- Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py 2006-11-17 12:30:35 UTC (rev 71150) +++ Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py 2006-11-17 13:22:41 UTC (rev 71151) @@ -5,9 +5,13 @@ class DummyDB: conn_num = 1 + +result = None -def query(self,*args): -return ('result for:',)+args +def query(self,query,max_rows): +if self.result: +return self.result +return 'result for ' + query def hook_method(self): conn_to_use = 'conn'+str(self.conn_num) @@ -34,13 +38,13 @@ self.da.cache_time_ = 10 self.da.max_cache_ = 2 -def _do_query(self,query,time): +def _do_query(self,query,t): try: -self.DA.time = DummyTime(time) -result = self.da._cached_result(DummyDB(),query) +self.DA.time = DummyTime(t) +result = self.da._cached_result(DummyDB(),query,1,'conn_id') finally: self.DA.time = time -self.assertEqual(result,('result for:',)+query) +self.assertEqual(result,'result for '+query) def _check_mapping(self,expected,actual): missing = [] @@ -101,10 +105,10 @@ # query, but where the item returned is always in the cache self._check_cache({},{}) for t in range(1,6): -self._do_query(('query',),t) +self._do_query('query',t) self._check_cache( -{('query', '\nDBConnId: None'): (1,('result for:', 'query'))}, -{1: ('query', '\nDBConnId: None')} +{('query',1,'conn_id'): (1,'result for query')}, +{1: ('query',1,'conn_id')} ) def test_same_query_same_second(self): @@ -115,10 +119,10 @@ self._check_cache({},{}) for t in range(11,16,1): t = float(t)/10 -self._do_query(('query',),t) +self._do_query('query',t) self._check_cache( -{('query', '\nDBConnId: None'): (1.1,('result for:', 'query'))}, -{1: ('query', '\nDBConnId: None')} +{('query',1,'conn_id'): (1.1,'result for query')}, +{1: ('query',1,'conn_id')} ) def test_different_queries_different_second(self): @@ -128,49 +132,49 @@ # dumped due to the replacement of Bucket with dict self._check_cache({},{}) # one -self._do_query(('query1',),1.1) +
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py more documentary tests:
Log message for revision 71153: more documentary tests: - document 2 memory leaks, one in cache and one in tcache - test coverage for the patch Brian applied in Dec 2000 Changed: U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py -=- Modified: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py === --- Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py 2006-11-17 14:04:28 UTC (rev 71152) +++ Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py 2006-11-17 15:32:54 UTC (rev 71153) @@ -180,7 +180,7 @@ def test_different_queries_same_second(self): # This tests different queries being fired into the cache # in the same second. -# XXX The demonstrates a memory leak in the cache code +# XXX The demonstrates 2 memory leaks in the cache code self._check_cache({},{}) # one self._do_query('query1',1.0) @@ -191,6 +191,7 @@ # two self._do_query( 'query2',1.1) self._check_cache( +# XXX oops, query1 is in the cache but it'll never be purged. {('query1',1,'conn_id'): (1.0,'result for query1'), ('query2',1,'conn_id'): (1.1,'result for query2'),}, {1.0: ('query2',1,'conn_id'),} @@ -198,6 +199,7 @@ # three self._do_query('query3',1.2) self._check_cache( +# XXX oops, query1 and query2 are in the cache but will never be purged {('query1',1,'conn_id'): (1,'result for query1'), ('query2',1,'conn_id'): (1.1,'result for query2'), ('query3',1,'conn_id'): (1.2,'result for query3'),}, @@ -206,7 +208,7 @@ # four - now we drop our first cache entry, this is an off-by-one error self._do_query('query4',1.3) self._check_cache( -# XXX - oops, why is query1 here still? +# XXX - oops, why is query1 here still? see above ;-) {('query1',1,'conn_id'): (1,'result for query1'), ('query2',1,'conn_id'): (1.1,'result for query2'), ('query3',1,'conn_id'): (1.2,'result for query3'), @@ -216,7 +218,7 @@ # five - now we drop another cache entry self._do_query('query5',1.4) self._check_cache( -# XXX - oops, why are query1 and query2 here still? +# XXX - oops, why are query1 and query2 here still? see above ;-) {('query1',1,'conn_id'): (1,'result for query1'), ('query2',1,'conn_id'): (1.1,'result for query2'), ('query3',1,'conn_id'): (1.2,'result for query3'), @@ -225,6 +227,69 @@ {1: ('query5',1,'conn_id'),} ) +def test_time_tcache_expires(self): +# the first query gets cached +self._do_query('query1',1) +self._check_cache( +{('query1',1,'conn_id'): (1,'result for query1')}, +{1: ('query1',1,'conn_id')} +) +# the 2nd gets cached, the cache is still smaller than max_cache / 2 +self._do_query('query2',12) +self._check_cache( +{('query1',1,'conn_id'): (1,'result for query1'), + ('query2',1,'conn_id'): (12,'result for query2')}, +{1: ('query1',1,'conn_id'), + 12:('query2',1,'conn_id')} +) +# the 2rd trips the max_cache/2 trigger, so both our old queries get +# dumped +self._do_query('query',23) +self._check_cache( +{('query',1,'conn_id'): (23,'result for query')}, +{23:('query',1,'conn_id')} +) + +def test_time_refreshed_cache(self): +# the first query gets cached +self._do_query('query1',1) +self._check_cache( +{('query1',1,'conn_id'): (1,'result for query1')}, +{1: ('query1',1,'conn_id')} +) +# do the same query much later, so new one gets cached +# XXX memory leak as old tcache entry is left lying around +self._do_query('query1',12) +self._check_cache( +{('query1',1,'conn_id'): (12,'result for query1')}, +{1: ('query1',1,'conn_id'), # XXX why is 1 still here? + 12: ('query1',1,'conn_id')} +) +def test_cachetime_doesnt_match_tcache_time(self): +# get some old entries for one query in +# (the time are carefully picked to give out-of-order dict keys) +self._do_query('query1',4) +self._do_query('query1',19) +self._do_query('query1',44) +self._check_cache( +{('query1',1,'conn_id'): (44,'result for query1')}, +{4: ('query1',1,'conn_id'), + 19: ('query1',1,'conn_id'), + 44: ('query1',1,'conn_id')} +) +# now do another query +self._do_query('query2',44.1) +# XXX whoops, because
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/ - stop rounding to ints, making memory leaks much less likely
Log message for revision 71158: - stop rounding to ints, making memory leaks much less likely - document the slim chances of remaining memory leaks - remove pointless import try/except, it always fails now - adjust tests to make sure we still generate pathalogical dict orderings Changed: U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py -=- Modified: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py === --- Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 16:03:10 UTC (rev 71157) +++ Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 16:54:02 UTC (rev 71158) @@ -39,8 +39,7 @@ from webdav.Resource import Resource from webdav.Lockable import ResourceLockedError from zExceptions import BadRequest -try: from IOBTree import Bucket -except: Bucket=lambda:{} +Bucket=lambda:{} class DatabaseError(BadRequest): @@ -369,7 +368,7 @@ key=keys[-1] q=tcache[key] del tcache[key] -if int(cache[q][0]) == key: +if cache[q][0] == key: del cache[q] del keys[-1] @@ -380,7 +379,20 @@ # call the pure query result=DB__.query(query,max_rows) if self.cache_time_ 0: -tcache[int(now)]=cache_key +# When a ZSQL method is handled by one ZPublisher thread twice in +# less time than it takes for time.time() to return a different +# value, the SQL generated is different, then this code will leak +# an entry in 'cache' for each time the ZSQL method generates +# different SQL until time.time() returns a different value. +# +# On Linux, you would need an extremely fast machine under extremely +# high load, making this extremely unlikely. On Windows, this is a +# little more likely, but still unlikely to be a problem. +# +# If it does become a problem, the values of the tcache mapping +# need to be turned into sets of cache keys rather than a single +# cache key. +tcache[now]=cache_key cache[cache_key]= now, result return result Modified: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py === --- Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py 2006-11-17 16:03:10 UTC (rev 71157) +++ Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py 2006-11-17 16:54:02 UTC (rev 71158) @@ -122,7 +122,7 @@ self._do_query('query',t) self._check_cache( {('query',1,'conn_id'): (1.1,'result for query')}, -{1: ('query',1,'conn_id')} +{1.1: ('query',1,'conn_id')} ) def test_different_queries_different_second(self): @@ -135,15 +135,15 @@ self._do_query('query1',1.1) self._check_cache( {('query1',1,'conn_id'): (1.1,'result for query1')}, -{1: ('query1',1,'conn_id')} +{1.1: ('query1',1,'conn_id')} ) # two self._do_query( 'query2',3.2) self._check_cache( {('query1',1,'conn_id'): (1.1,'result for query1'), ('query2',1,'conn_id'): (3.2,'result for query2'),}, -{1: ('query1',1,'conn_id'), - 3: ('query2',1,'conn_id'),} +{1.1: ('query1',1,'conn_id'), + 3.2: ('query2',1,'conn_id'),} ) # three self._do_query('query3',4.3) @@ -151,80 +151,83 @@ {('query1',1,'conn_id'): (1.1,'result for query1'), ('query2',1,'conn_id'): (3.2,'result for query2'), ('query3',1,'conn_id'): (4.3,'result for query3'),}, -{1: ('query1',1,'conn_id'), - 3: ('query2',1,'conn_id'), - 4: ('query3',1,'conn_id'),} +{1.1: ('query1',1,'conn_id'), + 3.2: ('query2',1,'conn_id'), + 4.3: ('query3',1,'conn_id'),} ) # four - now we drop our first cache entry, this is an off-by-one error self._do_query('query4',8.4) +# XXX oops - because dicts have an arbitary ordering, we dumped the wrong key! self._check_cache( {('query2',1,'conn_id'): (3.2,'result for query2'), - ('query3',1,'conn_id'): (4.3,'result for query3'), + ('query1',1,'conn_id'): (1.1,'result for query1'), ('query4',1,'conn_id'): (8.4,'result for query4'),}, -{3: ('query2',1,'conn_id'), - 4: ('query3',1,'conn_id'), - 8: ('query4',1,'conn_id'),} +{1.1: ('query1',1,'conn_id'), + 3.2: ('query2',1,'conn_id'), + 8.4:
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/ - use an ordered mapping so we dump the oldest stuff from the cache first
Log message for revision 71161: - use an ordered mapping so we dump the oldest stuff from the cache first - remove the pointless check for cache time being enabled inside _cached_result - _cached_result isn't actually called if caching isn't enabled - slight code tidy in DA.py - lots of comments in the test_caching.py and DA.py's _cached_result method Changed: U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py U Zope/branches/2.9/lib/python/Shared/DC/ZRDB/tests/test_caching.py -=- Modified: Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py === --- Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 17:23:22 UTC (rev 71160) +++ Zope/branches/2.9/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 18:15:27 UTC (rev 71161) @@ -39,7 +39,7 @@ from webdav.Resource import Resource from webdav.Lockable import ResourceLockedError from zExceptions import BadRequest -Bucket=lambda:{} +from BTrees.OOBTree import OOBucket as Bucket class DatabaseError(BadRequest): @@ -352,27 +352,52 @@ def _searchable_result_columns(self): return self._col def _cached_result(self, DB__, query, max_rows, conn_id): +# Try to fetch a result from the cache. +# Compute and cache the result otherwise. +# Also maintains the cache and ensures stale entries +# are never returned and that the cache never gets too large. + +# NB: Correct cache behavior is predicated on Bucket.keys() +# returning a sequence ordered from smalled number +# (ie: the oldest cache entry) to largest number +# (ie: the newest cache entry). Please be careful if you +# change the class instantied below! + +# get hold of a cache +caches = getattr(self,'_v_cache',None) +if caches is None: +caches = self._v_cache = {}, Bucket() +cache, tcache = caches + +# the key for caching cache_key = query,max_rows,conn_id - -# Try to fetch from cache -if hasattr(self,'_v_cache'): cache=self._v_cache -else: cache=self._v_cache={}, Bucket() -cache, tcache = cache +# the maximum number of result sets to cache max_cache=self.max_cache_ +# the current time now=time() +# the oldest time which is not stale t=now-self.cache_time_ + +# if the cache is too big, we purge entries from it if len(cache) = max_cache: keys=tcache.keys() -keys.reverse() -while keys and (len(keys) = max_cache or keys[-1] t): -key=keys[-1] +# We also hoover out any stale entries, as we're +# already doing cache minimisation. +# 'keys' is ordered, so we purge the oldest results +# until the cache is small enough and there are no +# stale entries in it +while keys and (len(keys) = max_cache or keys[0] t): +key=keys[0] q=tcache[key] del tcache[key] del cache[q] -del keys[-1] +del keys[0] +# okay, now see if we have a cached result if cache.has_key(cache_key): k, r = cache[cache_key] +# the result may still be stale, as we only hoover out +# stale results above if the cache gets too large. if k t: # yay! a cached result returned! return r @@ -383,23 +408,23 @@ # call the pure query result=DB__.query(query,max_rows) -if self.cache_time_ 0: -# When a ZSQL method is handled by one ZPublisher thread twice in -# less time than it takes for time.time() to return a different -# value, the SQL generated is different, then this code will leak -# an entry in 'cache' for each time the ZSQL method generates -# different SQL until time.time() returns a different value. -# -# On Linux, you would need an extremely fast machine under extremely -# high load, making this extremely unlikely. On Windows, this is a -# little more likely, but still unlikely to be a problem. -# -# If it does become a problem, the values of the tcache mapping -# need to be turned into sets of cache keys rather than a single -# cache key. -tcache[now]=cache_key -cache[cache_key]= now, result +# When a ZSQL method is handled by one ZPublisher thread twice in +# less time than it takes for time.time() to return a different +# value, the SQL generated is different, then this code will leak +# an entry in 'cache' for each time the ZSQL method generates +# different SQL until time.time() returns a different value. +# +
[Zope-Checkins] SVN: Zope/branches/2.9/doc/CHANGES.txt change log for recent DA.py work.
Log message for revision 71162: change log for recent DA.py work. Changed: U Zope/branches/2.9/doc/CHANGES.txt -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2006-11-17 18:15:27 UTC (rev 71161) +++ Zope/branches/2.9/doc/CHANGES.txt 2006-11-17 18:21:08 UTC (rev 71162) @@ -9,6 +9,18 @@ Bugs fixed + - Reworking of _cached_result in Shared.DC.ZRDB.DA.DA: + +- fixed KeyError reported in Collector #2212 + +- fixed two memory leaks that occurred under high load + +- fixed broken cache keys for people using the obscure + Shared.DC.ZRDB.DA.DA.connection_hook + +- fixed incorrect cache ordering resulting in newer results + being dumped when the cache became too large. + - Collector #2237: 'make' doesn't tell you to run 'make inplace' before running 'make instance'. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Shared/DC/ZRDB/ merge of DA.py caching work from 2.9 branch:
Log message for revision 71163: merge of DA.py caching work from 2.9 branch: - Reworking of _cached_result in Shared.DC.ZRDB.DA.DA: - fixed KeyError reported in Collector #2212 - fixed two memory leaks that occurred under high load - fixed broken cache keys for people using the obscure Shared.DC.ZRDB.DA.DA.connection_hook - fixed incorrect cache ordering resulting in newer results being dumped when the cache became too large. Changed: U Zope/branches/2.10/lib/python/Shared/DC/ZRDB/DA.py A Zope/branches/2.10/lib/python/Shared/DC/ZRDB/tests/test_caching.py -=- Modified: Zope/branches/2.10/lib/python/Shared/DC/ZRDB/DA.py === --- Zope/branches/2.10/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 18:21:08 UTC (rev 71162) +++ Zope/branches/2.10/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 18:27:15 UTC (rev 71163) @@ -44,8 +44,7 @@ from webdav.Resource import Resource from webdav.Lockable import ResourceLockedError from zExceptions import BadRequest -try: from IOBTree import Bucket -except: Bucket=lambda:{} +from BTrees.OOBTree import OOBucket as Bucket class DatabaseError(BadRequest): @@ -357,40 +356,80 @@ def _searchable_result_columns(self): return self._col -def _cached_result(self, DB__, query): -pure_query = query -# we need to munge the incoming query key in the cache -# so that the same request to a different db is returned -query = query + ('\nDBConnId: %s' % self.connection_hook, ) - -# Try to fetch from cache -if hasattr(self,'_v_cache'): cache=self._v_cache -else: cache=self._v_cache={}, Bucket() -cache, tcache = cache +def _cached_result(self, DB__, query, max_rows, conn_id): +# Try to fetch a result from the cache. +# Compute and cache the result otherwise. +# Also maintains the cache and ensures stale entries +# are never returned and that the cache never gets too large. + +# NB: Correct cache behavior is predicated on Bucket.keys() +# returning a sequence ordered from smalled number +# (ie: the oldest cache entry) to largest number +# (ie: the newest cache entry). Please be careful if you +# change the class instantied below! + +# get hold of a cache +caches = getattr(self,'_v_cache',None) +if caches is None: +caches = self._v_cache = {}, Bucket() +cache, tcache = caches + +# the key for caching +cache_key = query,max_rows,conn_id +# the maximum number of result sets to cache max_cache=self.max_cache_ +# the current time now=time() +# the oldest time which is not stale t=now-self.cache_time_ -if len(cache) max_cache / 2: + +# if the cache is too big, we purge entries from it +if len(cache) = max_cache: keys=tcache.keys() -keys.reverse() -while keys and (len(keys) max_cache or keys[-1] t): -key=keys[-1] +# We also hoover out any stale entries, as we're +# already doing cache minimisation. +# 'keys' is ordered, so we purge the oldest results +# until the cache is small enough and there are no +# stale entries in it +while keys and (len(keys) = max_cache or keys[0] t): +key=keys[0] q=tcache[key] del tcache[key] -if int(cache[q][0]) == key: -del cache[q] -del keys[-1] +del cache[q] +del keys[0] -if cache.has_key(query): -k, r = cache[query] -if k t: return r +# okay, now see if we have a cached result +if cache.has_key(cache_key): +k, r = cache[cache_key] +# the result may still be stale, as we only hoover out +# stale results above if the cache gets too large. +if k t: +# yay! a cached result returned! +return r +else: +# delete stale cache entries +del cache[cache_key] +del tcache[k] # call the pure query -result=apply(DB__.query, pure_query) -if self.cache_time_ 0: -tcache[int(now)]=query -cache[query]= now, result +result=DB__.query(query,max_rows) +# When a ZSQL method is handled by one ZPublisher thread twice in +# less time than it takes for time.time() to return a different +# value, the SQL generated is different, then this code will leak +# an entry in 'cache' for each time the ZSQL method generates +# different SQL until time.time() returns a different value. +
[Zope-Checkins] SVN: Zope/branches/2.10/doc/CHANGES.txt change log for recent DA.py work
Log message for revision 71164: change log for recent DA.py work Changed: U Zope/branches/2.10/doc/CHANGES.txt -=- Modified: Zope/branches/2.10/doc/CHANGES.txt === --- Zope/branches/2.10/doc/CHANGES.txt 2006-11-17 18:27:15 UTC (rev 71163) +++ Zope/branches/2.10/doc/CHANGES.txt 2006-11-17 18:29:50 UTC (rev 71164) @@ -8,6 +8,18 @@ Bugs fixed + - Reworking of _cached_result in Shared.DC.ZRDB.DA.DA: + +- fixed KeyError reported in Collector #2212 + +- fixed two memory leaks that occurred under high load + +- fixed broken cache keys for people using the obscure + Shared.DC.ZRDB.DA.DA.connection_hook + +- fixed incorrect cache ordering resulting in newer results + being dumped when the cache became too large. + - Collector #2232: Can't call DTML templates from Page Templates - Collector #2213: Can't edit old ZopePageTemplate instances. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Shared/DC/ZRDB/ merge of DA.py caching work from 2.9 branch:
Log message for revision 71165: merge of DA.py caching work from 2.9 branch: - Reworking of _cached_result in Shared.DC.ZRDB.DA.DA: - fixed KeyError reported in Collector #2212 - fixed two memory leaks that occurred under high load - fixed broken cache keys for people using the obscure Shared.DC.ZRDB.DA.DA.connection_hook - fixed incorrect cache ordering resulting in newer results being dumped when the cache became too large. Changed: U Zope/trunk/lib/python/Shared/DC/ZRDB/DA.py A Zope/trunk/lib/python/Shared/DC/ZRDB/tests/test_caching.py -=- Modified: Zope/trunk/lib/python/Shared/DC/ZRDB/DA.py === --- Zope/trunk/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 18:29:50 UTC (rev 71164) +++ Zope/trunk/lib/python/Shared/DC/ZRDB/DA.py 2006-11-17 18:31:29 UTC (rev 71165) @@ -44,8 +44,7 @@ from webdav.Resource import Resource from webdav.Lockable import ResourceLockedError from zExceptions import BadRequest -try: from IOBTree import Bucket -except: Bucket=lambda:{} +from BTrees.OOBTree import OOBucket as Bucket class DatabaseError(BadRequest): @@ -357,40 +356,80 @@ def _searchable_result_columns(self): return self._col -def _cached_result(self, DB__, query): -pure_query = query -# we need to munge the incoming query key in the cache -# so that the same request to a different db is returned -query = query + ('\nDBConnId: %s' % self.connection_hook, ) - -# Try to fetch from cache -if hasattr(self,'_v_cache'): cache=self._v_cache -else: cache=self._v_cache={}, Bucket() -cache, tcache = cache +def _cached_result(self, DB__, query, max_rows, conn_id): +# Try to fetch a result from the cache. +# Compute and cache the result otherwise. +# Also maintains the cache and ensures stale entries +# are never returned and that the cache never gets too large. + +# NB: Correct cache behavior is predicated on Bucket.keys() +# returning a sequence ordered from smalled number +# (ie: the oldest cache entry) to largest number +# (ie: the newest cache entry). Please be careful if you +# change the class instantied below! + +# get hold of a cache +caches = getattr(self,'_v_cache',None) +if caches is None: +caches = self._v_cache = {}, Bucket() +cache, tcache = caches + +# the key for caching +cache_key = query,max_rows,conn_id +# the maximum number of result sets to cache max_cache=self.max_cache_ +# the current time now=time() +# the oldest time which is not stale t=now-self.cache_time_ -if len(cache) max_cache / 2: + +# if the cache is too big, we purge entries from it +if len(cache) = max_cache: keys=tcache.keys() -keys.reverse() -while keys and (len(keys) max_cache or keys[-1] t): -key=keys[-1] +# We also hoover out any stale entries, as we're +# already doing cache minimisation. +# 'keys' is ordered, so we purge the oldest results +# until the cache is small enough and there are no +# stale entries in it +while keys and (len(keys) = max_cache or keys[0] t): +key=keys[0] q=tcache[key] del tcache[key] -if int(cache[q][0]) == key: -del cache[q] -del keys[-1] +del cache[q] +del keys[0] -if cache.has_key(query): -k, r = cache[query] -if k t: return r +# okay, now see if we have a cached result +if cache.has_key(cache_key): +k, r = cache[cache_key] +# the result may still be stale, as we only hoover out +# stale results above if the cache gets too large. +if k t: +# yay! a cached result returned! +return r +else: +# delete stale cache entries +del cache[cache_key] +del tcache[k] # call the pure query -result=apply(DB__.query, pure_query) -if self.cache_time_ 0: -tcache[int(now)]=query -cache[query]= now, result +result=DB__.query(query,max_rows) +# When a ZSQL method is handled by one ZPublisher thread twice in +# less time than it takes for time.time() to return a different +# value, the SQL generated is different, then this code will leak +# an entry in 'cache' for each time the ZSQL method generates +# different SQL until time.time() returns a different value. +# +# On Linux, you would
Re: [Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ fix #2235 for real now
Leonardo Rochael Almeida wrote: @@ -615,8 +615,8 @@ def getobject(self, rid, REQUEST=None): Return a cataloged object given a 'data_record_id_' -obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid)) -if not obj: +obj = self.aq_parent.unrestrictedTraverse(self.getpath(rid), None) +if obj is None: Please revert this change. You've changed the semantics of this statement and it will now mask errors in traversing to the path. This is bad... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/tags/2.9.3/inst/WinBuilders/ tweak versions.
Log message for revision 68265: tweak versions. Changed: U Zope/tags/2.9.3/inst/WinBuilders/README.txt U Zope/tags/2.9.3/inst/WinBuilders/mk/python.mk -=- Modified: Zope/tags/2.9.3/inst/WinBuilders/README.txt === --- Zope/tags/2.9.3/inst/WinBuilders/README.txt 2006-05-24 15:55:48 UTC (rev 68264) +++ Zope/tags/2.9.3/inst/WinBuilders/README.txt 2006-05-24 16:45:32 UTC (rev 68265) @@ -6,7 +6,7 @@ Setup Environment -- -Install Python 2.4.2 (or whatever is most current) by running its native +Install Python 2.4.3 (or whatever is most current) by running its native Windows installer from python.org. Note: Python 2.4 switched from using a Wise installer to using a @@ -35,9 +35,9 @@ a tmp directory, inst/tmp. Place the necessary pre-requisites in the tmp directory. At the time of this writing, these are: - - Python-2.4.2.tgz - - pywin32-207.win32-py2.4.exe - - Zope-2.9.1.tgz + - Python-2.4.3.tgz + - pywin32-208.win32-py2.4.exe + - Zope-2.9.3.tgz As time marches on, these version numbers will obviously change. See/edit mk/python.mk and mk/zope.mk for the exact versions required. Modified: Zope/tags/2.9.3/inst/WinBuilders/mk/python.mk === --- Zope/tags/2.9.3/inst/WinBuilders/mk/python.mk 2006-05-24 15:55:48 UTC (rev 68264) +++ Zope/tags/2.9.3/inst/WinBuilders/mk/python.mk 2006-05-24 16:45:32 UTC (rev 68265) @@ -15,8 +15,8 @@ # a compiler. PYVERSION_MAJOR := 2 PYVERSION_MINOR := 4 -PYVERSION_PATCH := 2 -W32ALLVERSION := 207 +PYVERSION_PATCH := 3 +W32ALLVERSION := 208 PYVERSION := $(PYVERSION_MAJOR).$(PYVERSION_MINOR).$(PYVERSION_PATCH) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/inst/WinBuilders/ tweak versions.
Log message for revision 68266: tweak versions. Changed: U Zope/branches/2.9/inst/WinBuilders/README.txt U Zope/branches/2.9/inst/WinBuilders/mk/python.mk -=- Modified: Zope/branches/2.9/inst/WinBuilders/README.txt === --- Zope/branches/2.9/inst/WinBuilders/README.txt 2006-05-24 16:45:32 UTC (rev 68265) +++ Zope/branches/2.9/inst/WinBuilders/README.txt 2006-05-24 16:51:18 UTC (rev 68266) @@ -6,7 +6,7 @@ Setup Environment -- -Install Python 2.4.2 (or whatever is most current) by running its native +Install Python 2.4.3 (or whatever is most current) by running its native Windows installer from python.org. Note: Python 2.4 switched from using a Wise installer to using a @@ -35,9 +35,9 @@ a tmp directory, inst/tmp. Place the necessary pre-requisites in the tmp directory. At the time of this writing, these are: - - Python-2.4.2.tgz - - pywin32-207.win32-py2.4.exe - - Zope-2.9.1.tgz + - Python-2.4.3.tgz + - pywin32-208.win32-py2.4.exe + - Zope-2.9.3.tgz As time marches on, these version numbers will obviously change. See/edit mk/python.mk and mk/zope.mk for the exact versions required. Modified: Zope/branches/2.9/inst/WinBuilders/mk/python.mk === --- Zope/branches/2.9/inst/WinBuilders/mk/python.mk 2006-05-24 16:45:32 UTC (rev 68265) +++ Zope/branches/2.9/inst/WinBuilders/mk/python.mk 2006-05-24 16:51:18 UTC (rev 68266) @@ -15,8 +15,8 @@ # a compiler. PYVERSION_MAJOR := 2 PYVERSION_MINOR := 4 -PYVERSION_PATCH := 2 -W32ALLVERSION := 207 +PYVERSION_PATCH := 3 +W32ALLVERSION := 208 PYVERSION := $(PYVERSION_MAJOR).$(PYVERSION_MINOR).$(PYVERSION_PATCH) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/inst/WinBuilders/ tweak versions.
Log message for revision 68267: tweak versions. Changed: U Zope/trunk/inst/WinBuilders/README.txt U Zope/trunk/inst/WinBuilders/mk/python.mk -=- Modified: Zope/trunk/inst/WinBuilders/README.txt === --- Zope/trunk/inst/WinBuilders/README.txt 2006-05-24 16:51:18 UTC (rev 68266) +++ Zope/trunk/inst/WinBuilders/README.txt 2006-05-24 17:01:05 UTC (rev 68267) @@ -6,7 +6,7 @@ Setup Environment -- -Install Python 2.4.2 (or whatever is most current) by running its native +Install Python 2.4.3 (or whatever is most current) by running its native Windows installer from python.org. Note: Python 2.4 switched from using a Wise installer to using a @@ -35,9 +35,9 @@ a tmp directory, inst/tmp. Place the necessary pre-requisites in the tmp directory. At the time of this writing, these are: - - Python-2.4.2.tgz - - pywin32-207.win32-py2.4.exe - - Zope-2.10.0b1.tgz + - Python-2.4.3.tgz + - pywin32-208.win32-py2.4.exe + - Zope-2.9.3.tgz As time marches on, these version numbers will obviously change. See/edit mk/python.mk and mk/zope.mk for the exact versions required. Modified: Zope/trunk/inst/WinBuilders/mk/python.mk === --- Zope/trunk/inst/WinBuilders/mk/python.mk2006-05-24 16:51:18 UTC (rev 68266) +++ Zope/trunk/inst/WinBuilders/mk/python.mk2006-05-24 17:01:05 UTC (rev 68267) @@ -15,8 +15,8 @@ # a compiler. PYVERSION_MAJOR := 2 PYVERSION_MINOR := 4 -PYVERSION_PATCH := 2 -W32ALLVERSION := 207 +PYVERSION_PATCH := 3 +W32ALLVERSION := 208 PYVERSION := $(PYVERSION_MAJOR).$(PYVERSION_MINOR).$(PYVERSION_PATCH) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Products/PluginIndexes/ quieten more down.
Log message for revision 68138: quieten more down. Changed: U Zope/branches/2.9/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py U Zope/branches/2.9/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py U Zope/branches/2.9/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py -=- Modified: Zope/branches/2.9/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py === --- Zope/branches/2.9/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py 2006-05-15 20:02:31 UTC (rev 68137) +++ Zope/branches/2.9/lib/python/Products/PluginIndexes/KeywordIndex/KeywordIndex.py 2006-05-15 20:21:03 UTC (rev 68138) @@ -127,7 +127,7 @@ try: del self._unindex[documentId] except KeyError: -LOG.error('Attempt to unindex nonexistent' +LOG.debug('Attempt to unindex nonexistent' ' document id %s' % documentId) manage = manage_main = DTMLFile('dtml/manageKeywordIndex', globals()) Modified: Zope/branches/2.9/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py === --- Zope/branches/2.9/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2006-05-15 20:02:31 UTC (rev 68137) +++ Zope/branches/2.9/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2006-05-15 20:21:03 UTC (rev 68138) @@ -132,7 +132,7 @@ hook for (Z)Catalog if not self._unindex.has_key(docid): -LOG.error('Attempt to unindex nonexistent document with id %s' +LOG.debug('Attempt to unindex nonexistent document with id %s' % docid) return @@ -150,7 +150,7 @@ if not self._index[comp]: del self._index[comp] except KeyError: -LOG.error('Attempt to unindex document with id %s failed' +LOG.debug('Attempt to unindex document with id %s failed' % docid) self._length.change(-1) Modified: Zope/branches/2.9/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py === --- Zope/branches/2.9/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py 2006-05-15 20:02:31 UTC (rev 68137) +++ Zope/branches/2.9/lib/python/Products/PluginIndexes/TopicIndex/TopicIndex.py 2006-05-15 20:21:03 UTC (rev 68138) @@ -80,7 +80,7 @@ try: fs.unindex_object(docid) except KeyError: -LOG.error('Attempt to unindex document' +LOG.debug('Attempt to unindex document' ' with id %s failed' % docid) return 1 ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Products/PluginIndexes/common/UnIndex.py while this is interesting, is doesn't warrant spewing at error.
Log message for revision 68093: while this is interesting, is doesn't warrant spewing at error. Changed: U Zope/branches/2.9/lib/python/Products/PluginIndexes/common/UnIndex.py -=- Modified: Zope/branches/2.9/lib/python/Products/PluginIndexes/common/UnIndex.py === --- Zope/branches/2.9/lib/python/Products/PluginIndexes/common/UnIndex.py 2006-05-10 21:01:20 UTC (rev 68092) +++ Zope/branches/2.9/lib/python/Products/PluginIndexes/common/UnIndex.py 2006-05-11 10:01:26 UTC (rev 68093) @@ -301,7 +301,7 @@ except ConflictError: raise except: -LOG.error('Attempt to unindex nonexistent document' +LOG.debug('Attempt to unindex nonexistent document' ' with id %s' % documentId) def _apply_index(self, request, cid='', type=type): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py while this is interesting, is doesn't warrant spewing at error.
Log message for revision 68094: while this is interesting, is doesn't warrant spewing at error. Changed: U Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py -=- Modified: Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py === --- Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py 2006-05-11 10:01:26 UTC (rev 68093) +++ Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py 2006-05-11 10:02:17 UTC (rev 68094) @@ -301,7 +301,7 @@ except ConflictError: raise except: -LOG.error('Attempt to unindex nonexistent document' +LOG.debug('Attempt to unindex nonexistent document' ' with id %s' % documentId) def _apply_index(self, request, cid='', type=type): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py a traceback would probably help here ; -)
Log message for revision 68095: a traceback would probably help here ;-) Changed: U Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py -=- Modified: Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py === --- Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py 2006-05-11 10:02:17 UTC (rev 68094) +++ Zope/trunk/lib/python/Products/PluginIndexes/common/UnIndex.py 2006-05-11 10:07:45 UTC (rev 68095) @@ -302,7 +302,7 @@ raise except: LOG.debug('Attempt to unindex nonexistent document' - ' with id %s' % documentId) + ' with id %s' % documentId,exc_info=True) def _apply_index(self, request, cid='', type=type): Apply the index to query parameters given in the request arg. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/skel/bin/runzope.bat.in changes so it's easier to move a Zope instance between zope versions.
Log message for revision 67786: changes so it's easier to move a Zope instance between zope versions. Changed: U Zope/trunk/skel/bin/runzope.bat.in -=- Modified: Zope/trunk/skel/bin/runzope.bat.in === --- Zope/trunk/skel/bin/runzope.bat.in 2006-05-01 10:12:03 UTC (rev 67785) +++ Zope/trunk/skel/bin/runzope.bat.in 2006-05-01 11:13:52 UTC (rev 67786) @@ -1,8 +1,8 @@ @set PYTHON=PYTHON @set ZOPE_HOME=ZOPE_HOME @set INSTANCE_HOME=INSTANCE_HOME [EMAIL PROTECTED] SOFTWARE_HOME=SOFTWARE_HOME [EMAIL PROTECTED] CONFIG_FILE=INSTANCE_HOME\etc\zope.conf [EMAIL PROTECTED] SOFTWARE_HOME=%ZOPE_HOME%\lib\python [EMAIL PROTECTED] CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf @set PYTHONPATH=%SOFTWARE_HOME% @set ZOPE_RUN=%SOFTWARE_HOME%\Zope2\Startup\run.py %PYTHON% %ZOPE_RUN% -C %CONFIG_FILE% %1 %2 %3 %4 %5 %6 %7 ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/skel/bin/runzope.bat.in further changes so it's easier to move an instance between zope versions.
Log message for revision 67788: further changes so it's easier to move an instance between zope versions. Changed: U Zope/trunk/skel/bin/runzope.bat.in -=- Modified: Zope/trunk/skel/bin/runzope.bat.in === --- Zope/trunk/skel/bin/runzope.bat.in 2006-05-01 11:14:30 UTC (rev 67787) +++ Zope/trunk/skel/bin/runzope.bat.in 2006-05-01 11:19:33 UTC (rev 67788) @@ -1,6 +1,6 @@ [EMAIL PROTECTED] PYTHON=PYTHON @set ZOPE_HOME=ZOPE_HOME @set INSTANCE_HOME=INSTANCE_HOME [EMAIL PROTECTED] PYTHON=%ZOPE_HOME%\bin\python.exe @set SOFTWARE_HOME=%ZOPE_HOME%\lib\python @set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf @set PYTHONPATH=%SOFTWARE_HOME% ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/skel/bin/runzope.bat.in further changes so it's easier to move an instance between zope versions.
Log message for revision 67789: further changes so it's easier to move an instance between zope versions. Changed: U Zope/branches/2.9/skel/bin/runzope.bat.in -=- Modified: Zope/branches/2.9/skel/bin/runzope.bat.in === --- Zope/branches/2.9/skel/bin/runzope.bat.in 2006-05-01 11:19:33 UTC (rev 67788) +++ Zope/branches/2.9/skel/bin/runzope.bat.in 2006-05-01 11:19:56 UTC (rev 67789) @@ -1,6 +1,6 @@ [EMAIL PROTECTED] PYTHON=PYTHON @set ZOPE_HOME=ZOPE_HOME @set INSTANCE_HOME=INSTANCE_HOME [EMAIL PROTECTED] PYTHON=%ZOPE_HOME%\bin\python.exe @set SOFTWARE_HOME=%ZOPE_HOME%\lib\python @set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf @set PYTHONPATH=%SOFTWARE_HOME% ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py Fix test failures on Windows.
Log message for revision 67792: Fix test failures on Windows. Changed: U Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py -=- Modified: Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py === --- Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py 2006-05-01 12:05:40 UTC (rev 67791) +++ Zope/trunk/lib/python/OFS/tests/test_XMLExportImport.py 2006-05-01 12:06:18 UTC (rev 67792) @@ -11,6 +11,7 @@ # ## import unittest +import os import tempfile import transaction from StringIO import StringIO @@ -68,16 +69,20 @@ transaction.savepoint(optimistic=True) # need an OID! oid = dm._p_oid -ostream = tempfile.NamedTemporaryFile(suffix='.xml') +handle, path = tempfile.mkstemp(suffix='.xml') try: +ostream = os.fdopen(handle,'wb') data = exportXML(connection, oid, ostream) -ostream.flush() -newobj = importXML(connection, ostream.name) +ostream.close() +newobj = importXML(connection, path) +self.failUnless(isinstance(newobj, DTMLMethod)) +self.assertEqual(newobj.read(), dm.read()) finally: -ostream.close() +# if this operaiton fails with a 'Permission Denied' error, +# then comment it out as it's probably masking a failure in +# the block above. +os.remove(path) -self.failUnless(isinstance(newobj, DTMLMethod)) -self.assertEqual(newobj.read(), dm.read()) def test_OFS_ObjectManager__importObjectFromFile_xml(self): from OFS.DTMLMethod import DTMLMethod @@ -95,13 +100,17 @@ oid = dm._p_oid sub = app._getOb('sub') -ostream = tempfile.NamedTemporaryFile(suffix='.xml') +handle, path = tempfile.mkstemp(suffix='.xml') try: +ostream = os.fdopen(handle,'wb') data = exportXML(connection, oid, ostream) -ostream.flush() -sub._importObjectFromFile(ostream.name, 0, 0) +ostream.close() +sub._importObjectFromFile(path, 0, 0) finally: -ostream.close() +# if this operaiton fails with a 'Permission Denied' error, +# then comment it out as it's probably masking a failure in +# the block above. +os.remove(path) def test_suite(): return unittest.TestSuite(( ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/OFS/subscribers.py remove zLOG use.
Log message for revision 67798: remove zLOG use. Changed: U Zope/branches/2.9/lib/python/OFS/subscribers.py -=- Modified: Zope/branches/2.9/lib/python/OFS/subscribers.py === --- Zope/branches/2.9/lib/python/OFS/subscribers.py 2006-05-01 14:12:47 UTC (rev 67797) +++ Zope/branches/2.9/lib/python/OFS/subscribers.py 2006-05-01 14:14:26 UTC (rev 67798) @@ -18,9 +18,8 @@ import warnings -import sys +from logging import getLogger -from zLOG import LOG, ERROR from Acquisition import aq_base from App.config import getConfiguration from AccessControl import getSecurityManager @@ -35,6 +34,7 @@ deprecatedManageAddDeleteClasses = [] +LOG = getLogger('OFS.subscribers') def compatibilityCall(method_name, *args): Call a method if events have not been setup yet. @@ -152,7 +152,7 @@ except ConflictError: raise except: -LOG('Zope', ERROR, '_delObject() threw', error=sys.exc_info()) +LOG.error('_delObject() threw', exc_info=True) # In debug mode when non-Manager, let exceptions propagate. if getConfiguration().debug_mode: if not getSecurityManager().getUser().has_role('Manager'): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/OFS/tests/test shush log output from tests.
Log message for revision 67801: shush log output from tests. Changed: U Zope/branches/2.9/lib/python/OFS/tests/testAppInitializer.py U Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py U Zope/branches/2.9/lib/python/OFS/tests/testProductInit.py -=- Modified: Zope/branches/2.9/lib/python/OFS/tests/testAppInitializer.py === --- Zope/branches/2.9/lib/python/OFS/tests/testAppInitializer.py 2006-05-01 14:27:29 UTC (rev 67800) +++ Zope/branches/2.9/lib/python/OFS/tests/testAppInitializer.py 2006-05-01 14:27:56 UTC (rev 67801) @@ -14,6 +14,8 @@ import os, sys, unittest, tempfile, cStringIO +from logging import getLogger + import ZODB from OFS.Application import Application, AppInitializer, get_products import Zope2.Startup @@ -121,7 +123,12 @@ i = self.getOne() self.configure(bad_cfg) -status = i.install_tempfolder_and_sdc() +try: +logger = getLogger('Zope.ZODBMountPoint') +logger.disabled = 1 +status = i.install_tempfolder_and_sdc() +finally: +logger.disabled = 0 self.failIf(status) def test_install_tempfolder_and_sdc_unlimited_sessions(self): Modified: Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py === --- Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py 2006-05-01 14:27:29 UTC (rev 67800) +++ Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py 2006-05-01 14:27:56 UTC (rev 67801) @@ -7,6 +7,7 @@ from AccessControl.SpecialUsers import emergency_user, nobody, system from Acquisition import Implicit from App.config import getConfiguration +from logging import getLogger from OFS.ObjectManager import ObjectManager from OFS.SimpleItem import SimpleItem from zope.app.testing.placelesssetup import PlacelessSetup @@ -14,6 +15,7 @@ from Products.Five import zcml from Products.Five.eventconfigure import setDeprecatedManageAddDelete +logger = getLogger('OFS.subscribers') class FauxRoot( Implicit ): @@ -284,7 +286,11 @@ om = self._makeOne() ob = ItemForDeletion(fail_on_delete=True) om._setObject(ob.getId(), ob) -om._delObject(ob.getId()) +try: +logger.disabled = 1 +om._delObject(ob.getId()) +finally: +logger.disabled = 0 def test_delObject_exception(self): # Test exception behavior in manage_beforeDelete @@ -293,8 +299,12 @@ om = self._makeOne() ob = ItemForDeletion(fail_on_delete=True) om._setObject(ob.getId(), ob) -om._delObject(ob.getId()) - +try: +logger.disabled = 1 +om._delObject(ob.getId()) +finally: +logger.disabled = 0 + def test_delObject_exception_debug_manager(self): # Test exception behavior in manage_beforeDelete in debug mode # Manager user @@ -303,7 +313,11 @@ om = self._makeOne() ob = ItemForDeletion(fail_on_delete=True) om._setObject(ob.getId(), ob) -om._delObject(ob.getId()) +try: +logger.disabled = 1 +om._delObject(ob.getId()) +finally: +logger.disabled = 0 def test_delObject_exception_debug(self): # Test exception behavior in manage_beforeDelete in debug mode @@ -313,7 +327,11 @@ om = self._makeOne() ob = ItemForDeletion(fail_on_delete=True) om._setObject(ob.getId(), ob) -self.assertRaises(DeleteFailed, om._delObject, ob.getId()) +try: +logger.disabled = 1 +self.assertRaises(DeleteFailed, om._delObject, ob.getId()) +finally: +logger.disabled = 0 def test_delObject_exception_debug_deep(self): # Test exception behavior in manage_beforeDelete in debug mode @@ -325,7 +343,11 @@ ob = ItemForDeletion(fail_on_delete=True) om1._setObject('om2', om2, set_owner=False) om2._setObject(ob.getId(), ob) -self.assertRaises(DeleteFailed, om1._delObject, 'om2') +try: +logger.disabled = 1 +self.assertRaises(DeleteFailed, om1._delObject, 'om2') +finally: +logger.disabled = 0 def test_hasObject(self): om = self._makeOne() Modified: Zope/branches/2.9/lib/python/OFS/tests/testProductInit.py === --- Zope/branches/2.9/lib/python/OFS/tests/testProductInit.py 2006-05-01 14:27:29 UTC (rev 67800) +++ Zope/branches/2.9/lib/python/OFS/tests/testProductInit.py 2006-05-01 14:27:56 UTC (rev 67801) @@ -170,7 +170,14 @@ f.write('Syntax Error!') f.close() self.configure(cfg) -self.assertRaises(SyntaxError, self.import_bad_product) +try: +from logging
[Zope-Checkins] SVN: Zope/branches/2.9/ - Collector #2062: Fix manage_historyCopy, which was broken, and write tests for it.
Log message for revision 67804: - Collector #2062: Fix manage_historyCopy, which was broken, and write tests for it. Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/OFS/History.py A Zope/branches/2.9/lib/python/OFS/tests/testHistory.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2006-05-01 15:20:47 UTC (rev 67803) +++ Zope/branches/2.9/doc/CHANGES.txt 2006-05-01 15:39:48 UTC (rev 67804) @@ -18,6 +18,9 @@ Bugs fixed + - Collector #2062: Fix manage_historyCopy, which was broken, and write +tests for it. + - Collector #2061: Fix problems where windows line endings are passed to restricted code compilers. Modified: Zope/branches/2.9/lib/python/OFS/History.py === --- Zope/branches/2.9/lib/python/OFS/History.py 2006-05-01 15:20:47 UTC (rev 67803) +++ Zope/branches/2.9/lib/python/OFS/History.py 2006-05-01 15:39:48 UTC (rev 67804) @@ -144,15 +144,12 @@ if serial != self._p_serial: self.manage_beforeHistoryCopy() state=self._p_jar.oldstate(self, serial) -# Scrub the object before restoring the old state base = aq_base(self) -base._p_changed=0 -base._p_deactivate() -base.__setstate__(state) -base._p_changed=1 - +base._p_activate() # make sure we're not a ghost +base.__setstate__(state) # change the state +base._p_changed = True # marke object as dirty self.manage_afterHistoryCopy() - + if RESPONSE is not None and URL1 is not None: RESPONSE.redirect(URL1+'/manage_workspace') Added: Zope/branches/2.9/lib/python/OFS/tests/testHistory.py === --- Zope/branches/2.9/lib/python/OFS/tests/testHistory.py 2006-05-01 15:20:47 UTC (rev 67803) +++ Zope/branches/2.9/lib/python/OFS/tests/testHistory.py 2006-05-01 15:39:48 UTC (rev 67804) @@ -0,0 +1,97 @@ +import unittest +import Testing +import Zope2 +Zope2.startup() + +import os +import shutil +import transaction +import tempfile +import ZODB + +from OFS.Application import Application +from Products.PythonScripts.PythonScript import manage_addPythonScript +from ZODB.FileStorage import FileStorage + +class HistoryTests(unittest.TestCase): + +def setUp(self): +# set up a zodb +# we can't use DemoStorage here 'cos it doesn't support History +self.dir = tempfile.mkdtemp() +self.s = FileStorage(os.path.join(self.dir,'testHistory.fs'),create=True) +self.connection = ZODB.DB(self.s).open() +r = self.connection.root() +a = Application() +r['Application'] = a +self.root = a +# create a python script +manage_addPythonScript(a,'test') +self.ps = ps = a.test +# commit some changes +ps.write('return 1') +t = transaction.get() +# undo note made by Application instantiation above. +t.description = None +t.note('Change 1') +t.commit() +ps.write('return 2') +t = transaction.get() +t.note('Change 2') +t.commit() +ps.write('return 3') +t = transaction.get() +t.note('Change 3') +t.commit() + +def tearDown(self): +# get rid of ZODB +transaction.abort() +self.connection.close() +self.s.close() +del self.root +del self.connection +del self.s +shutil.rmtree(self.dir) + +def test_manage_change_history(self): +r = self.ps.manage_change_history() +self.assertEqual(len(r),3) # three transactions +for i in range(3): +entry = r[i] +# check no new keys show up without testing +self.assertEqual(len(entry.keys()),7) +# the transactions are in newest-first order +self.assertEqual(entry['description'],'Change %i' % (3-i)) +self.failUnless('key' in entry) +# lets not assume the size will stay the same forever +self.failUnless('size' in entry) +self.failUnless('tid' in entry) +self.failUnless('time' in entry) +if i: +# check times are increasing +self.failUnless(entry['time']r[i-1]['time']) +self.assertEqual(entry['user_name'],'') +self.assertEqual(entry['version'],'') + +def test_manage_historyCopy(self): +# we assume this works 'cos it's tested above +r = self.ps.manage_change_history() +# now we do the copy +self.ps.manage_historyCopy( +keys=[r[2]['key']] + ) +# do a commit, just
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py if it's inefficient, don't do it unless it's used ; -)
Log message for revision 66374: if it's inefficient, don't do it unless it's used ;-) Changed: U Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py -=- Modified: Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py === --- Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2006-04-04 10:02:50 UTC (rev 66373) +++ Zope/trunk/lib/python/Products/ZCatalog/ZCatalog.py 2006-04-04 10:23:48 UTC (rev 66374) @@ -485,11 +485,10 @@ name = (name,) paths = self._catalog.uids.keys() -num_paths = len(paths) # inefficient i = 0 if pghandler: -pghandler.init('reindexing %s' % name, num_paths) +pghandler.init('reindexing %s' % name, len(paths)) for p in paths: i+=1 ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py if it's inefficient, don't do it unless it's used ; -)
Log message for revision 66375: if it's inefficient, don't do it unless it's used ;-) Changed: U Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py -=- Modified: Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py === --- Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py 2006-04-04 10:23:48 UTC (rev 66374) +++ Zope/branches/2.9/lib/python/Products/ZCatalog/ZCatalog.py 2006-04-04 10:25:23 UTC (rev 66375) @@ -481,11 +481,10 @@ name = (name,) paths = self._catalog.uids.keys() -num_paths = len(paths) # inefficient i = 0 if pghandler: -pghandler.init('reindexing %s' % name, num_paths) +pghandler.init('reindexing %s' % name, len(paths)) for p in paths: i+=1 ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] SVN: Zope/tags/Zope-2-8-6/ forgotten to tag r41770 as Zope-2-8.6 release
What happened to Zope/tags/2.8.6 as the naming convention? Chris Andreas Jung wrote: Log message for revision 66042: forgotten to tag r41770 as Zope-2-8.6 release Changed: A Zope/tags/Zope-2-8-6/ -=- Copied: Zope/tags/Zope-2-8-6 (from rev 41770, Zope/branches/Zope-2_8-branch) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py Fix missing import :-S
Log message for revision 41574: Fix missing import :-S Changed: U Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py === --- Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py 2006-02-07 15:29:16 UTC (rev 41573) +++ Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py 2006-02-08 10:51:24 UTC (rev 41574) @@ -280,9 +280,10 @@ except AttributeError: # Most likely some product forgot to call __of__() # on the user object. -LOG('AccessControl', WARNING, -'A user object of type %s has no aq_parent.' -% str(type(auth_user))) +ac_logger.warning( +'A user object of type %s has no aq_parent.', +type(auth_user) +) auth_path = request_get('AUTHENTICATION_PATH') else: auth_path = '/'.join(auth_folder.getPhysicalPath()[1:-1]) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Zope2/App/startup.py Fix missing import.
Log message for revision 41575: Fix missing import. Changed: U Zope/branches/2.9/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py === --- Zope/branches/2.9/lib/python/Zope2/App/startup.py 2006-02-08 10:51:24 UTC (rev 41574) +++ Zope/branches/2.9/lib/python/Zope2/App/startup.py 2006-02-08 10:53:48 UTC (rev 41575) @@ -287,9 +287,10 @@ except AttributeError: # Most likely some product forgot to call __of__() # on the user object. -LOG('AccessControl', WARNING, -'A user object of type %s has no aq_parent.' -% str(type(auth_user))) +ac_logger.warning( +'A user object of type %s has no aq_parent.', +type(auth_user) +) auth_path = request_get('AUTHENTICATION_PATH') else: auth_path = '/'.join(auth_folder.getPhysicalPath()[1:-1]) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Zope2/App/startup.py Fix missing import :-S
Log message for revision 41576: Fix missing import :-S Changed: U Zope/trunk/lib/python/Zope2/App/startup.py -=- Modified: Zope/trunk/lib/python/Zope2/App/startup.py === --- Zope/trunk/lib/python/Zope2/App/startup.py 2006-02-08 10:53:48 UTC (rev 41575) +++ Zope/trunk/lib/python/Zope2/App/startup.py 2006-02-08 10:55:20 UTC (rev 41576) @@ -285,9 +285,10 @@ except AttributeError: # Most likely some product forgot to call __of__() # on the user object. -LOG('AccessControl', WARNING, -'A user object of type %s has no aq_parent.' -% str(type(auth_user))) +ac_logger.warning( +'A user object of type %s has no aq_parent.', +type(auth_user) +) auth_path = request_get('AUTHENTICATION_PATH') else: auth_path = '/'.join(auth_folder.getPhysicalPath()[1:-1]) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/Transience/Transience.py remove unused import.
Log message for revision 40465: remove unused import. Changed: U Zope/trunk/lib/python/Products/Transience/Transience.py -=- Modified: Zope/trunk/lib/python/Products/Transience/Transience.py === --- Zope/trunk/lib/python/Products/Transience/Transience.py 2005-12-02 10:36:37 UTC (rev 40464) +++ Zope/trunk/lib/python/Products/Transience/Transience.py 2005-12-02 12:10:29 UTC (rev 40465) @@ -36,7 +36,6 @@ from Persistence import Persistent from OFS.SimpleItem import SimpleItem -from ZPublisher.Publish import Retry from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl.SecurityManagement import newSecurityManager, \ setSecurityManager ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/OFS/SimpleItem.py - change to use python logging module
Log message for revision 40468: - change to use python logging module - log at error when standard_error_message can't be rendered - give more useful info about errors rendering standard_error_message to the browser. Changed: U Zope/trunk/lib/python/OFS/SimpleItem.py -=- Modified: Zope/trunk/lib/python/OFS/SimpleItem.py === --- Zope/trunk/lib/python/OFS/SimpleItem.py 2005-12-02 13:35:48 UTC (rev 40467) +++ Zope/trunk/lib/python/OFS/SimpleItem.py 2005-12-02 13:45:58 UTC (rev 40468) @@ -32,12 +32,12 @@ from AccessControl.ZopeSecurityPolicy import getRoles from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire from ComputedAttribute import ComputedAttribute +from DocumentTemplate.html_quote import html_quote from DocumentTemplate.ustr import ustr from ExtensionClass import Base from webdav.Resource import Resource from zExceptions import Redirect from zExceptions.ExceptionFormatter import format_exception -from zLOG import LOG, BLATHER from zope.interface import implements import ZDOM @@ -49,6 +49,8 @@ HTML=Globals.HTML +import logging +logger = logging.getLogger() class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ZDOM.Element, @@ -226,17 +228,21 @@ else: v = HTML.__call__(s, client, REQUEST, **kwargs) except: -LOG('OFS', BLATHER, +logger.error( 'Exception while rendering an error message', -error=sys.exc_info()) +exc_info=True +) try: strv = str(error_value) except: -strv = ('unprintable %s object' % +strv = ('unprintable %s object' % str(type(error_value).__name__)) v = strv + ( - (Also, an error occurred while attempting -to render the standard error message.)) +( (Also, the following error occurred while attempting + to render the standard error message, please see the + event log for full details: %s))%( +html_quote(sys.exc_info()[1]), +)) raise error_type, v, tb finally: if hasattr(self, '_v_eek'): del self._v_eek ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Z further changes to ConflictError logging:
Log message for revision 40472: further changes to ConflictError logging: - all conflict errors are counted and logged at info, as they were before Florent's change - logging makes it clear where the conflict has been resolved and where it hasn't - errors seen by the user are rendered with standard_error_message and are sent to the error_log which will likely copy them to the event log, depending on the users setup. - also checking in a functional test for generating write conflict errors. (I'll be committing to CHANGES.TXT shortly, I just wanted to keep the merges simpler) Changed: A Zope/trunk/lib/python/ZPublisher/tests/generate_conflicts.py U Zope/trunk/lib/python/Zope2/App/startup.py -=- Added: Zope/trunk/lib/python/ZPublisher/tests/generate_conflicts.py === --- Zope/trunk/lib/python/ZPublisher/tests/generate_conflicts.py 2005-12-02 14:34:07 UTC (rev 40471) +++ Zope/trunk/lib/python/ZPublisher/tests/generate_conflicts.py 2005-12-02 14:35:08 UTC (rev 40472) @@ -0,0 +1,91 @@ +## This script requires: +## - python2.4 +## - Zope 3's zope.testbrowser package: +## http://www.zope.org/Members/benji_york/ZopeTestbrowser-0.9.0.tgz +## +## The just run: +## $python2.4 generate_conflicts.py +import base64 +import string +import threading +import urllib2 + +from zope.testbrowser.browser import Browser + +# create our browser +class AuthBrowser(Browser): + +def addBasicAuth(self,username,password): +self.addHeader( +'Authorization', +'Basic '+base64.encodestring(username+':'+password).strip() +) + +def open(self,uri,include_server=True): +if include_server: +uri = server+uri +return Browser.open(self,uri) + +browser = AuthBrowser() + +# constants +server = 'http://localhost:8080' +# the following user must be able to view the management screens +# and create file objects +username = 'username' +password = 'password' +browser.addBasicAuth(username,password) +threads = 10 +filename = 'conflict.txt' +filesize = 1 +hits = 5 + +# delete the file if it's already there +browser.open('/manage_main') +if filename in [c.optionValue +for c in browser.getControl(name='ids:list').controls]: +browser.open('/manage_delObjects?ids:list='+filename) + +# create it +browser.open('/manage_addFile?id='+filename) + +# edit it, hopefully causing conflicts +data = 'X'*filesize +class EditThread(threading.Thread): + +def __init__(self,i): +self.conflicts = 0 +self.browser = AuthBrowser() +self.browser.handleErrors = False +self.browser.addBasicAuth(username,password) +threading.Thread.__init__(self,name=str(i)) + +def run(self): +for i in range(1,hits+1): +self.browser.open('/conflict.txt/manage_main') +self.browser.getControl(name='title').value='Test Title' +self.browser.getControl(name='filedata:text').value = data +try: +self.browser.getControl(name='manage_edit:method').click() +except urllib2.HTTPError,e: +# print e.read() +self.conflicts += 1 +print Thread %s - CONFLICT % self.getName() +else: +print Thread %s - EDIT % self.getName() + +thread_objects = [] +for i in range(1,threads+1): +t = EditThread(i) +thread_objects.append(t) +t.start() +for t in thread_objects: +t.join() +total = 0 +print +for t in thread_objects: +print Thread %s - %i conflicts seen % (t.getName(),t.conflicts) +total += t.conflicts +print +print %i conflicts seen by browsers % total + Property changes on: Zope/trunk/lib/python/ZPublisher/tests/generate_conflicts.py ___ Name: svn:eol-style + native Modified: Zope/trunk/lib/python/Zope2/App/startup.py === --- Zope/trunk/lib/python/Zope2/App/startup.py 2005-12-02 14:34:07 UTC (rev 40471) +++ Zope/trunk/lib/python/Zope2/App/startup.py 2005-12-02 14:35:08 UTC (rev 40472) @@ -18,9 +18,9 @@ from AccessControl.SecurityManagement import noSecurityManager from Acquisition import aq_acquire from App.config import getConfiguration +from time import asctime from types import StringType, ListType from zExceptions import Unauthorized -from zLOG import LOG, ERROR, WARNING, INFO, BLATHER, log_time from ZODB.POSException import ConflictError import transaction import AccessControl.User @@ -28,6 +28,7 @@ import ExtensionClass import Globals import imp +import logging import OFS.Application import os import sys @@ -103,7 +104,7 @@ noSecurityManager() global startup_time -startup_time = log_time() +startup_time = asctime() Zope2.zpublisher_transactions_manager = TransactionsManager()
[Zope-Checkins] SVN: Zope/trunk/lib/python/Zope2/App/startup.py *sigh* failed to correctly merge my own patch.
Log message for revision 40475: *sigh* failed to correctly merge my own patch. Changed: U Zope/trunk/lib/python/Zope2/App/startup.py -=- Modified: Zope/trunk/lib/python/Zope2/App/startup.py === --- Zope/trunk/lib/python/Zope2/App/startup.py 2005-12-02 14:45:53 UTC (rev 40474) +++ Zope/trunk/lib/python/Zope2/App/startup.py 2005-12-02 15:10:44 UTC (rev 40475) @@ -221,6 +221,7 @@ finally: traceback=None +ac_logger = logging.getLogger('event.AccessControl') class TransactionsManager: def begin(self, @@ -237,7 +238,7 @@ def recordMetaData(self, object, request, # Optimize global var lookups: hasattr=hasattr, getattr=getattr, - LOG=LOG, WARNING=WARNING, + logger=ac_logger, ): request_get = request.get if hasattr(object, 'getPhysicalPath'): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/ Merge error reporting changes from trunk:
Log message for revision 40476: Merge error reporting changes from trunk: - remove unused import. - change SimpleItem.py to use python logging module - log at error when standard_error_message can't be rendered - give more useful info about errors rendering standard_error_message to the browser. - all conflict errors are counted and logged at info - logging makes it clear where the conflict has been resolved and where it hasn't - errors seen by the user are rendered with standard_error_message and are sent to the error_log which will likely copy them to the event log, depending on the users setup. - also checking in a functional test for generating write conflict errors. (I'll be committing to CHANGES.TXT shortly, I just wanted to keep the merges simpler) Changed: U Zope/branches/Zope-2_8-branch/lib/python/OFS/SimpleItem.py U Zope/branches/Zope-2_8-branch/lib/python/Products/Transience/Transience.py A Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/generate_conflicts.py U Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/Zope-2_8-branch/lib/python/OFS/SimpleItem.py === --- Zope/branches/Zope-2_8-branch/lib/python/OFS/SimpleItem.py 2005-12-02 15:10:44 UTC (rev 40475) +++ Zope/branches/Zope-2_8-branch/lib/python/OFS/SimpleItem.py 2005-12-02 15:44:31 UTC (rev 40476) @@ -30,10 +30,10 @@ from AccessControl import getSecurityManager, Unauthorized from AccessControl.ZopeSecurityPolicy import getRoles from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire +from DocumentTemplate.html_quote import html_quote from DocumentTemplate.ustr import ustr from zExceptions.ExceptionFormatter import format_exception from zExceptions import Redirect -from zLOG import LOG, BLATHER from CopySupport import CopySource from Traversable import Traversable @@ -41,6 +41,8 @@ HTML=Globals.HTML +import logging +logger = logging.getLogger() class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ZDOM.Element, @@ -210,17 +212,21 @@ else: v = HTML.__call__(s, client, REQUEST, **kwargs) except: -LOG('OFS', BLATHER, +logger.error( 'Exception while rendering an error message', -error=sys.exc_info()) +exc_info=True +) try: strv = str(error_value) except: strv = ('unprintable %s object' % str(type(error_value).__name__)) v = strv + ( - (Also, an error occurred while attempting -to render the standard error message.)) +( (Also, the following error occurred while attempting + to render the standard error message, please see the + event log for full details: %s))%( +html_quote(sys.exc_info()[1]), +)) raise error_type, v, tb finally: if hasattr(self, '_v_eek'): del self._v_eek Modified: Zope/branches/Zope-2_8-branch/lib/python/Products/Transience/Transience.py === --- Zope/branches/Zope-2_8-branch/lib/python/Products/Transience/Transience.py 2005-12-02 15:10:44 UTC (rev 40475) +++ Zope/branches/Zope-2_8-branch/lib/python/Products/Transience/Transience.py 2005-12-02 15:44:31 UTC (rev 40476) @@ -36,7 +36,6 @@ from Persistence import Persistent from OFS.SimpleItem import SimpleItem -from ZPublisher.Publish import Retry from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl.SecurityManagement import newSecurityManager, \ setSecurityManager Copied: Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/generate_conflicts.py (from rev 40472, Zope/trunk/lib/python/ZPublisher/tests/generate_conflicts.py) Property changes on: Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/generate_conflicts.py ___ Name: svn:eol-style + native Modified: Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py === --- Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py 2005-12-02 15:10:44 UTC (rev 40475) +++ Zope/branches/Zope-2_8-branch/lib/python/Zope2/App/startup.py 2005-12-02 15:44:31 UTC (rev 40476) @@ -18,9 +18,9 @@ from AccessControl.SecurityManagement import noSecurityManager from Acquisition import aq_acquire from App.config import getConfiguration +from time import asctime from types import StringType, ListType from zExceptions import Unauthorized -from zLOG import LOG, WARNING, INFO, BLATHER,
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/ - remove unused import.
Log message for revision 40478: - remove unused import. - change SimpleItem.py to use python logging module - log at error when standard_error_message can't be rendered - give more useful info about errors rendering standard_error_message to the browser. - all conflict errors are counted and logged at info - logging makes it clear where the conflict has been resolved and where it hasn't - errors seen by the user are rendered with standard_error_message and are sent to the error_log which will likely copy them to the event log, depending on the users setup. - also checking in a functional test for generating write conflict errors. (I'll be committing to CHANGES.TXT shortly, I just wanted to keep the merges simpler) Changed: U Zope/branches/2.9/lib/python/OFS/SimpleItem.py U Zope/branches/2.9/lib/python/Products/Transience/Transience.py A Zope/branches/2.9/lib/python/ZPublisher/tests/generate_conflicts.py U Zope/branches/2.9/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/2.9/lib/python/OFS/SimpleItem.py === --- Zope/branches/2.9/lib/python/OFS/SimpleItem.py 2005-12-02 15:46:29 UTC (rev 40477) +++ Zope/branches/2.9/lib/python/OFS/SimpleItem.py 2005-12-02 15:52:43 UTC (rev 40478) @@ -29,12 +29,12 @@ from AccessControl.ZopeSecurityPolicy import getRoles from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire from ComputedAttribute import ComputedAttribute +from DocumentTemplate.html_quote import html_quote from DocumentTemplate.ustr import ustr from ExtensionClass import Base from webdav.Resource import Resource from zExceptions import Redirect from zExceptions.ExceptionFormatter import format_exception -from zLOG import LOG, BLATHER from zope.interface import implements import ZDOM @@ -46,6 +46,8 @@ HTML=Globals.HTML +import logging +logger = logging.getLogger() class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ZDOM.Element, @@ -222,17 +224,21 @@ else: v = HTML.__call__(s, client, REQUEST, **kwargs) except: -LOG('OFS', BLATHER, +logger.error( 'Exception while rendering an error message', -error=sys.exc_info()) +exc_info=True +) try: strv = str(error_value) except: strv = ('unprintable %s object' % str(type(error_value).__name__)) v = strv + ( - (Also, an error occurred while attempting -to render the standard error message.)) +( (Also, the following error occurred while attempting + to render the standard error message, please see the + event log for full details: %s))%( +html_quote(sys.exc_info()[1]), +)) raise error_type, v, tb finally: if hasattr(self, '_v_eek'): del self._v_eek Modified: Zope/branches/2.9/lib/python/Products/Transience/Transience.py === --- Zope/branches/2.9/lib/python/Products/Transience/Transience.py 2005-12-02 15:46:29 UTC (rev 40477) +++ Zope/branches/2.9/lib/python/Products/Transience/Transience.py 2005-12-02 15:52:43 UTC (rev 40478) @@ -36,7 +36,6 @@ from Persistence import Persistent from OFS.SimpleItem import SimpleItem -from ZPublisher.Publish import Retry from AccessControl import ClassSecurityInfo, getSecurityManager from AccessControl.SecurityManagement import newSecurityManager, \ setSecurityManager Copied: Zope/branches/2.9/lib/python/ZPublisher/tests/generate_conflicts.py (from rev 40476, Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/generate_conflicts.py) Property changes on: Zope/branches/2.9/lib/python/ZPublisher/tests/generate_conflicts.py ___ Name: svn:eol-style + native Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py === --- Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-02 15:46:29 UTC (rev 40477) +++ Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-02 15:52:43 UTC (rev 40478) @@ -18,9 +18,9 @@ from AccessControl.SecurityManagement import noSecurityManager from Acquisition import aq_acquire from App.config import getConfiguration +from time import asctime from types import StringType, ListType from zExceptions import Unauthorized -from zLOG import LOG, ERROR, WARNING, INFO, BLATHER, log_time from ZODB.POSException import ConflictError import transaction import AccessControl.User @@ -28,6 +28,7 @@ import
[Zope-Checkins] SVN: Zope/branches/2.9/doc/CHANGES.txt Note changes to ConflictError logging.
Log message for revision 40479: Note changes to ConflictError logging. Changed: U Zope/branches/2.9/doc/CHANGES.txt -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2005-12-02 15:52:43 UTC (rev 40478) +++ Zope/branches/2.9/doc/CHANGES.txt 2005-12-02 15:54:13 UTC (rev 40479) @@ -28,11 +28,12 @@ - Using FastCGI is officially deprecated - - Improved logging of ConflictErrors. Now a log is made at level -BLATHER with traceback for any conflict retried. In addition, a -log is made at level ERROR for a conflict that can't be retried -anymore and is returned to the browser as an error. Nothing is -logged anymore at level INFO. + - Improved logging of ConflictErrors. All conflict errors are +logged at INFO, with counts of how many occurred and how many +were resolved. Tracebacks for all conflicts are logged a DEBUG +level, although these won't help anyone much. If a conflict +error is unresolved, it will now bubble up to error_log and +standard_error_message. - Fixed unclear security declarations. Warn when an attempt is made to have a security declaration on a nonexistent method. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PageTemplates/PageTemplate.py continue whack-a-mole'ing useless pagetemplate errors.
Log message for revision 40480: continue whack-a-mole'ing useless pagetemplate errors. Changed: U Zope/trunk/lib/python/Products/PageTemplates/PageTemplate.py -=- Modified: Zope/trunk/lib/python/Products/PageTemplates/PageTemplate.py === --- Zope/trunk/lib/python/Products/PageTemplates/PageTemplate.py 2005-12-02 15:54:13 UTC (rev 40479) +++ Zope/trunk/lib/python/Products/PageTemplates/PageTemplate.py 2005-12-02 15:58:14 UTC (rev 40480) @@ -131,7 +131,11 @@ self._cook() if self._v_errors: __traceback_supplement__ = (PageTemplateTracebackSupplement, self) -raise PTRuntimeError, 'Page Template %s has errors.' % self.id +raise PTRuntimeError, ( +'Page Template %s has errors: %s' % ( +self.id, +self._v_errors +)) return self._v_macros def pt_source_file(self): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplate.py continue whack-a-mole'ing useless pagetemplate errors.
Log message for revision 40481: continue whack-a-mole'ing useless pagetemplate errors. Changed: U Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplate.py -=- Modified: Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplate.py === --- Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplate.py 2005-12-02 15:58:14 UTC (rev 40480) +++ Zope/branches/2.9/lib/python/Products/PageTemplates/PageTemplate.py 2005-12-02 16:24:21 UTC (rev 40481) @@ -131,7 +131,11 @@ self._cook() if self._v_errors: __traceback_supplement__ = (PageTemplateTracebackSupplement, self) -raise PTRuntimeError, 'Page Template %s has errors.' % self.id +raise PTRuntimeError, ( +'Page Template %s has errors: %s' % ( +self.id, +self._v_errors +)) return self._v_macros def pt_source_file(self): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/lib/python/Products/PageTemplates/PageTemplate.py continue whack-a-mole'ing useless pagetemplate errors.
Log message for revision 40482: continue whack-a-mole'ing useless pagetemplate errors. Changed: U Zope/branches/Zope-2_8-branch/lib/python/Products/PageTemplates/PageTemplate.py -=- Modified: Zope/branches/Zope-2_8-branch/lib/python/Products/PageTemplates/PageTemplate.py === --- Zope/branches/Zope-2_8-branch/lib/python/Products/PageTemplates/PageTemplate.py 2005-12-02 16:24:21 UTC (rev 40481) +++ Zope/branches/Zope-2_8-branch/lib/python/Products/PageTemplates/PageTemplate.py 2005-12-02 16:25:25 UTC (rev 40482) @@ -131,7 +131,11 @@ self._cook() if self._v_errors: __traceback_supplement__ = (PageTemplateTracebackSupplement, self) -raise PTRuntimeError, 'Page Template %s has errors.' % self.id +raise PTRuntimeError, ( +'Page Template %s has errors: %s' % ( +self.id, +self._v_errors +)) return self._v_macros def pt_source_file(self): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins