[Zope-Checkins] CVS: Packages/ZEO - runzeo.py:1.15.6.6

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Packages/ZEO
In directory cvs.zope.org:/tmp/cvs-serv14402

Modified Files:
  Tag: Zope-2_7-branch
runzeo.py 
Log Message:

- Missing parameter on log call


=== Packages/ZEO/runzeo.py 1.15.6.5 => 1.15.6.6 ===
--- Packages/ZEO/runzeo.py:1.15.6.5 Tue Apr 12 22:54:54 2005
+++ Packages/ZEO/runzeo.py  Wed Apr 13 01:37:34 2005
@@ -310,7 +310,7 @@
 os.unlink(pidfile)
 info("removed PID file '%s'" % pidfile)
 except IOError:
-error("PID file '%s' could not be removed")
+error("PID file '%s' could not be removed" % pidfile)
 
 # Signal names
 

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Zope/inst - Makefile.win.in:1.6.2.4

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv13839

Modified Files:
  Tag: Zope-2_7-branch
Makefile.win.in 
Log Message:

- Add version_txt target
- Call version_txt target from install target


=== Zope/inst/Makefile.win.in 1.6.2.3 => 1.6.2.4 ===
--- Zope/inst/Makefile.win.in:1.6.2.3   Tue Apr 12 23:41:33 2005
+++ Zope/inst/Makefile.win.in   Wed Apr 13 01:36:26 2005
@@ -50,13 +50,17 @@
-$(RMRF) $(BUILD_BASE)
 
 # install: Install a software home.
-install: build
+install: build version_txt
$(PYTHON) "$(BASE_DIR)\setup.py" $(DISTUTILS_OPTS) install \
--prefix="$(PREFIX)" $(BUILD_FLAGS) $(INSTALL_FLAGS)
@ echo.
@ echo Zope binaries installed successfully.
@ echo Now run '$(PYTHON) $(PREFIX)\bin\mkzopeinstance.py'
 
+# version_txt: create a version file in lib/python/version.txt
+version_txt:
+   echo "Zope $(MAJOR_VERSION).$(MINOR_VERSION)-$(RELEASE_TAG)" >\
+  "$(BASE_DIR)/lib/python/version.txt"
 
 # clean:   Delete the build files and any binaries/bytecode files in
 #  the source directory for good measure.

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Zope/doc - WINDOWS.txt:1.1.2.1 INSTALL.txt:1.39.2.10

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Zope/doc
In directory cvs.zope.org:/tmp/cvs-serv27740/doc

Modified Files:
  Tag: Zope-2_7-branch
INSTALL.txt 
Added Files:
  Tag: Zope-2_7-branch
WINDOWS.txt 
Log Message:

Major service enhancements.  Service cleanly shuts down child, and if child
fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.


=== Added File Zope/doc/WINDOWS.txt ===
How to build and install Zope from source code on Windows.
--
These instructions appear to work for 2.7 and the trunk:

* 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 or pull from CVS.  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.7.
  > - 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.

* If you are running from CVS, the build may fail:
  See http://collector.zope.org/Zope/1530
  > running install_data
  > error: can't copy 'version.txt': no matching files
  > NMAKE : fatal error U1077: '"e:\src\python-2.3-cvs\pcbuild\python.exe"' : 
return code '0x1'
  > Stop.

  If you see this error, edit setup.py and comment the line referencing 
  'version.txt'

* 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}\run_zope.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}\zope_service.py
  to see the valid options.  You may want something like:
  % python {zope_instance}\zope_service.py --startup=auto install

  Once installed, it can be started any number of ways:
  - python {zope_instance}\zope_service.py start
  - Control Panel
  - net start service_short_name (eg, "net start Zope_-1227678699"


=== Zope/doc/INSTALL.txt 1.39.2.9 => 1.39.2.10 ===
--- Zope/doc/INSTALL.txt:1.39.2.9   Thu Mar 10 10:48:52 2005
+++ Zope/doc/INSTALL.txtTue Apr 12 23:41:33 2005
@@ -3,6 +3,9 @@
 
   Welcome to Zope!  This document describes building and installing
   Zope on UNIX and Linux.
+  
+  See WINDOWS.txt for information about Windows.  See the PLATFORMS
+  directory for notes about various other platforms.
 
 System requirements when building from source
 

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Zope/skel/bin - zopeservice.py.in:1.1.2.10

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Zope/skel/bin
In directory cvs.zope.org:/tmp/cvs-serv27740/skel/bin

Modified Files:
  Tag: Zope-2_7-branch
zopeservice.py.in 
Log Message:

Major service enhancements.  Service cleanly shuts down child, and if child
fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.


=== Zope/skel/bin/zopeservice.py.in 1.1.2.9 => 1.1.2.10 ===
--- Zope/skel/bin/zopeservice.py.in:1.1.2.9 Thu Dec 16 13:08:39 2004
+++ Zope/skel/bin/zopeservice.py.in Tue Apr 12 23:41:34 2005
@@ -38,8 +38,9 @@
 
   install : Installs the service
 
-  update : Updates the service, use this when you change
-   the service class implementation 
+  update : Updates the service.  Use this if you change any
+   configuration settings and need the service to be
+   re-registered.
 
   remove : Removes the service
 
@@ -53,13 +54,9 @@
 
   debug : Runs the service in debug mode
 
-You can view the usage options by running ntservice.py without any
+You can view the usage options by running this module without any
 arguments.
 
-Note: you may have to register the Python service program first,
-
-  win32\PythonService.exe /register
-
   Starting Zope
 
 Start Zope by clicking the 'start' button in the services control
@@ -74,19 +71,17 @@
 
   Event logging
 
-Zope events are logged to the NT application event log. Use the
-event viewer to keep track of Zope events.
+Service related events (such as startup, shutdown, or errors executing
+the Zope process) are logged to the NT application event log. Use the
+event viewer to see these events.
 
-Note: to successfully run this script, the Zope software home needs to be on
-the PYTHONPATH.
-"""
+Zope Events are still written to the Zope event logs.
 
-import os.path
-from os.path import dirname as dn
-import sys
+"""
+import sys, os
 
 # these are replacements from mkzopeinstance
-PYTHONW = r'<>'
+PYTHON = r'<>'
 SOFTWARE_HOME=r'<>'
 INSTANCE_HOME = r'<>'
 ZOPE_HOME = r'<>'
@@ -95,17 +90,35 @@
 CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
 PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZOPE_HOME
 
-os.environ['PYTHONPATH'] = SOFTWARE_HOME
+# Setup the environment, so sub-processes see these variables
+parts = os.environ.get("PYTHONPATH", "").split(os.pathsep)
+if SOFTWARE_HOME not in parts:
+parts = filter(None, [SOFTWARE_HOME] + parts)
+os.environ["PYTHONPATH"] = os.pathsep.join(parts)
+os.environ["INSTANCE_HOME"] = INSTANCE_HOME
+
+# Ensure SOFTWARE_HOME is on our current sys.path so we can import the
+# nt_svcutils package.
+if SOFTWARE_HOME not in sys.path:
+sys.path.insert(0, SOFTWARE_HOME)
 
 from nt_svcutils.service import Service
 
 servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower()))
 
 class InstanceService(Service):
-start_cmd = '"%s" "%s" -C "%s"' % (PYTHONW, ZOPE_RUN, CONFIG_FILE)
 _svc_name_ = servicename
 _svc_display_name_ = 'Zope instance at %s' % INSTANCE_HOME
-_exe_name_ = PYTHONSERVICE_EXE
+# _svc_description_ can also be set (but what to say isn't clear!)
+# If the exe we expect is not there, let the service framework search
+# for it.  This will be true for people running from source builds and
+# relying on pre-installed pythonservice.exe.
+# Note this is only used at install time, not runtime.
+if os.path.isfile(PYTHONSERVICE_EXE):
+_exe_name_ = PYTHONSERVICE_EXE
+
+process_runner = PYTHON
+process_args = '"%s" -C "%s"' % (ZOPE_RUN, CONFIG_FILE)
 
 if __name__ == '__main__':
 import win32serviceutil

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Zope/lib/python/nt_svcutils - service.py:1.1.2.2

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Zope/lib/python/nt_svcutils
In directory cvs.zope.org:/tmp/cvs-serv27740/lib/python/nt_svcutils

Modified Files:
  Tag: Zope-2_7-branch
service.py 
Log Message:

Major service enhancements.  Service cleanly shuts down child, and if child
fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.


=== Zope/lib/python/nt_svcutils/service.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/nt_svcutils/service.py:1.1.2.1  Wed Aug 20 10:45:07 2003
+++ Zope/lib/python/nt_svcutils/service.py  Tue Apr 12 23:41:34 2005
@@ -12,16 +12,12 @@
 #
 ##
 
-""" Windows NT/2K service installer/controller for Zope/ZEO/ZRS instance
-homes """
+"""Windows Services installer/controller for Zope/ZEO/ZRS instance homes"""
 
-import win32serviceutil
-import win32service
-import win32event
-import win32process
-import pywintypes
-import time
-import os
+import sys, os, time, threading, signal
+import win32api, win32event, win32file, win32pipe, win32process, win32security
+import win32service, win32serviceutil, servicemanager
+import pywintypes, winerror, win32con
 
 # the max seconds we're allowed to spend backing off
 BACKOFF_MAX = 300
@@ -32,52 +28,98 @@
 # a dead process)
 BACKOFF_INITIAL_INTERVAL = 5
 
+# We execute a new thread that captures the tail of the output from our child
+# process. If the child fails, it is written to the event log.
+# This process is unconditional, and the output is never written to disk
+# (except obviously via the event log entry)
+# Size of the blocks we read from the child process's output.
+CHILDCAPTURE_BLOCK_SIZE = 80
+# The number of BLOCKSIZE blocks we keep as process output.
+CHILDCAPTURE_MAX_BLOCKS = 200
+
 class Service(win32serviceutil.ServiceFramework):
-""" A class representing a Windows NT service that can manage an
-instance-home-based Zope/ZEO/ZRS processes """
+"""Base class for a Windows Server to manage an external process.
+
+Subclasses can be used to managed an instance home-based Zope or
+ZEO process.  The win32 Python service module registers a specific
+file and class for a service.  To manage an instance, a subclass
+should be created in the instance home.
+"""
 
 # The PythonService model requires that an actual on-disk class declaration
-# represent a single service.  Thus, the below definition of start_cmd,
+# represent a single service.  Thus, the definitions below for the instance
 # must be overridden in a subclass in a file within the instance home for
-# each instance.  The below-defined start_cmd (and _svc_display_name_
-# and _svc_name_) are just examples.
-
+# each instance.
+# The values below are just examples.
 _svc_name_ = r'Zope-Instance'
 _svc_display_name_ = r'Zope instance at C:\Zope-Instance'
 
-start_cmd = (
-r'"C:\Program Files\Zope-2.7.0-a1\bin\python.exe" '
-r'"C:\Program Files\Zope-2.7.0-a1\lib\python\Zope\Startup\run.py" '
-r'-C "C:\Zope-Instance\etc\zope.conf"'
-)
+process_runner = r'C:\Program Files\Zope-2.7.0-a1\bin\python.exe'
+process_args = r'{path_to}\run.py -C {path_to}\zope.conf'
+evtlog_name = 'Zope'
 
 def __init__(self, args):
 win32serviceutil.ServiceFramework.__init__(self, args)
+# Just say "Zope", instead of "Zope_-x"
+try:
+servicemanager.SetEventSourceName(self.evtlog_name)
+except AttributeError:
+# old pywin32 - that's ok.
+pass
 # Create an event which we will use to wait on.
 # The "service stop" request will set this event.
-self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
+# 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
 
 def SvcStop(self):
 # Before we do anything, tell the SCM we are starting the stop process.
 self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
-# stop the process if necessary
-try:
-win32process.TerminateProcess(self.hZope, 0)
-except pywintypes.error:
-# the process may already have been terminated
-pass
-# And set my event.
+self.onStop()
+# Set the stop event - the main loop takes care of termination.
 win32event.SetEvent(self.hWaitStop)
 
+def onStop(self):
+# A hook for subclasses to override
+pass
+
 def createProcess(self, cmd):
-return win32process.CreateProcess(
-None, cmd, None, None, 0, 0, None, None,
-w

[Zope-Checkins] CVS: Zope/inst - Makefile.win.in:1.6.2.3 configure.py:1.10.2.7

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv27740/inst

Modified Files:
  Tag: Zope-2_7-branch
Makefile.win.in configure.py 
Log Message:

Major service enhancements.  Service cleanly shuts down child, and if child
fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.


=== Zope/inst/Makefile.win.in 1.6.2.2 => 1.6.2.3 ===
--- Zope/inst/Makefile.win.in:1.6.2.2   Wed May 12 14:02:43 2004
+++ Zope/inst/Makefile.win.in   Tue Apr 12 23:41:33 2005
@@ -31,14 +31,14 @@
 XCOPY=xcopy /i /s /e /y
 COPY=copy
 
-.PHONY: clean install build unbuild
-.PHONY: default
-
 default: build
 # default: The default step (invoked when make is called without a target)
@ echo.
@ echo Zope built.  Next, do 'nmake install'.
-   @ echo
+   @ echo.
+
+.PHONY: clean install build unbuild
+.PHONY: default
 
 # build:   Do whatever 'setup.py build' implies
 build:
@@ -47,7 +47,7 @@
 
 # unbuild: Remove the build directory (undo the make build step)
 unbuild:
-   $(RMRF) $(BUILD_BASE)
+   -$(RMRF) $(BUILD_BASE)
 
 # install: Install a software home.
 install: build
@@ -62,7 +62,7 @@
 #  the source directory for good measure.
 clean: unbuild
$(CD) "$(BASE_DIR)
-   $(RM) /s *.pyc *.pyo *.dll *.o *.obj *.pyd
+   -$(RM) /s *.pyc *.pyo *.dll *.o *.obj *.pyd
 
 
 


=== Zope/inst/configure.py 1.10.2.6 => 1.10.2.7 ===
--- Zope/inst/configure.py:1.10.2.6 Tue Oct 21 10:29:14 2003
+++ Zope/inst/configure.py  Tue Apr 12 23:41:33 2005
@@ -23,7 +23,7 @@
 if sys.platform == 'win32':
 PREFIX = 'c:\\Zope-' + versions.ZOPE_MAJOR_VERSION
 IN_MAKEFILE = 'Makefile.win.in'
-MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake 
build"'
+MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake"'
 else:
 PREFIX = '/opt/Zope-' + versions.ZOPE_MAJOR_VERSION
 IN_MAKEFILE = 'Makefile.in'

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Zope/utilities - mkzopeinstance.py:1.2.2.8

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Zope/utilities
In directory cvs.zope.org:/tmp/cvs-serv27740/utilities

Modified Files:
  Tag: Zope-2_7-branch
mkzopeinstance.py 
Log Message:

Major service enhancements.  Service cleanly shuts down child, and if child
fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.


=== Zope/utilities/mkzopeinstance.py 1.2.2.7 => 1.2.2.8 ===
--- Zope/utilities/mkzopeinstance.py:1.2.2.7Wed Jul 14 01:00:23 2004
+++ Zope/utilities/mkzopeinstance.pyTue Apr 12 23:41:34 2005
@@ -93,9 +93,11 @@
 user, password = get_inituser()
 
 # we need to distinguish between python.exe and pythonw.exe under
-# Windows in order to make Zope run using python.exe when run in a
-# console window and pythonw.exe when run as a service, so we do a bit
-# of sniffing here.
+# Windows.  Zope is always run using 'python.exe' (even for services),
+# however, it may be installed via pythonw.exe (as a sub-process of an
+# installer).  Thus, sys.executable may not be the executable we use.
+# We still provide both PYTHON and PYTHONW, but PYTHONW should never
+# need be used.
 psplit = os.path.split(sys.executable)
 exedir = os.path.join(*psplit[:-1])
 pythonexe = os.path.join(exedir, 'python.exe')

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Packages/Zope/Startup - __init__.py:1.7.2.7

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Packages/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv20056

Modified Files:
  Tag: Zope-2_7-branch
__init__.py 
Log Message:

* Register the new signal handlers on Windows


=== Packages/Zope/Startup/__init__.py 1.7.2.6 => 1.7.2.7 ===
--- Packages/Zope/Startup/__init__.py:1.7.2.6   Fri Jan 14 14:48:20 2005
+++ Packages/Zope/Startup/__init__.py   Tue Apr 12 23:12:08 2005
@@ -98,7 +98,7 @@
 zLOG.LOG('Zope', zLOG.ERROR, msg)
 
 def registerSignals(self):
-if os.name == 'posix':
+if os.name in ('posix','nt'):
 from Signals import Signals
 Signals.registerZopeSignals()
 

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Packages/Signals - WinSignalHandler.py:1.1.2.1 Signals.py:1.1.60.2

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Packages/Signals
In directory cvs.zope.org:/tmp/cvs-serv19174

Modified Files:
  Tag: Zope-2_7-branch
Signals.py 
Added Files:
  Tag: Zope-2_7-branch
WinSignalHandler.py 
Log Message:

* Implement a signal mechanism for Windows utilising Windows 'Named Events'.
  See comments in WinSignalHandler.py for details.
* As Windows can not rename an open file, when the 'reopen' signal is
  received try and call a 'rotate' method rather than a reopen.  Rotation
  itself is implemented in zLOG.LogHandler


=== Added File Packages/Signals/WinSignalHandler.py ===
##
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##

"""Signal handling dispatcher for Windows."""

# This code "simulates" Unix signals via Windows events.  When a signal is
# registered, we simply create a global named event for that signal.  The
# signal can be set by any user with the correct permission opening and
# setting the event.
#
# One event is used per signal, and the event name is based on both the
# Zope process ID and the signal number.  For example, assuming a process
# ID of 123, a SIGINT handler would create an event called "Zope-123-2" 
# (as signal.SIGINT==2).  The logfile reopen handler uses an event named
# "Zope-123-12" (as the logfile handler uses SIGUSR2, which == 12)

# The following program will send such an event:
#   import sys, win32event
#   hev = win32event.OpenEvent(win32event.EVENT_MODIFY_STATE, 0, sys.argv[1])
#   win32event.SetEvent(hev)
# A good way to get the PID is to read the var/*.pid file for the app.

# This code is only the generic signal mechanism for Windows.
# The signal handlers are still external, just like for other platforms.

# NOTE: There is one huge semantic difference between these "signals"
# and signals on Unix.  On Windows, the signals are delivered asynchronously
# to a thread inside this module.  This thread calls the event handler 
# directly - there is no magic to switch the call back to the main thread.
# If this is a problem (not currently, but likely later), one option may be 
# to add yet another asyncore handler - the thread in this module could 
# then "post" the request to the main thread via this asyncore handler.

import sys, os
import signal
import threading
import asyncore
import atexit
import Lifetime

# SetConsoleCtrlHandler not in early pywin32 versions - Signals.py will
# catch the import error.
from win32api import SetConsoleCtrlHandler
import win32con
import win32event
import pywintypes
import ntsecuritycon

# PEP 282/Z3 style logging.
import zLOG
def _log(msg, severity=zLOG.INFO, error=None):
zLOG.LOG("WinSignalHandler", severity, msg, "", error)
class Logger:
def error(self, msg):
_log(msg, zLOG.ERROR)

def exception(self, msg):
_log(msg, zLOG.ERROR, error=sys.exc_info())

def warn(self, msg):
_log(msg, zLOG.PROBLEM)
warning=warn

def info(self, msg):
_log(msg, zLOG.INFO)

def debug(self, msg):
_log(msg, zLOG.DEBUG)
logger=Logger()

# We simulate signals via win32 named events.  This is the event name
# prefix we use - the "signal number" is appended to this name.
event_name_prefix = "Zope-%d-" % os.getpid()

# For Windows 2000 and later, we prefix "Global\" to the name, so that
# it works correctly in a Terminal Services environment.
winver = sys.getwindowsversion()
# 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_prefix = "Global\\" + event_name_prefix

def createEventSecurityObject():
# Create a security object giving World read/write access,
# but only "Owner" modify access.
sa = pywintypes.SECURITY_ATTRIBUTES()
sidEveryone = pywintypes.SID()
sidEveryone.Initialize(ntsecuritycon.SECURITY_WORLD_SID_AUTHORITY,1)
sidEveryone.SetSubAuthority(0, ntsecuritycon.SECURITY_WORLD_RID)
sidCreator = pywintypes.SID()
sidCreator.Initialize(ntsecuritycon.SECURITY_CREATOR_SID_AUTHORITY,1)
sidCreator.SetSubAuthority(0, ntsecuritycon.SECURITY_CREATOR_OWNER_RID)

acl = pywintypes.ACL()
acl.AddAccessAllowedAce(win32event.EVENT_MODIFY_STATE, sidEveryone)
acl.AddAccessAllowedAce(ntsecuritycon.FILE_ALL_ACCESS, sidCreator)

sa.SetSecurityDescriptorDacl(1, acl, 0)
return sa

def wakeSelect():
"""Interrupt a sleeping asy

[Zope-Checkins] CVS: Packages/zLOG - LogHandlers.py:1.6.14.3

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Packages/zLOG
In directory cvs.zope.org:/tmp/cvs-serv16249

Modified Files:
  Tag: Zope-2_7-branch
LogHandlers.py 
Log Message:

* Implement a file handler with 'rotate'.  This closes the file, attempts
  a rename to {filename}.last, then reopens the original name.  This
  then makes the log available for another process to perform the rotation
  logic on. This log handler is only installed on the Windows
  platform, where you can't rename an open file.


=== Packages/zLOG/LogHandlers.py 1.6.14.2 => 1.6.14.3 ===
--- Packages/zLOG/LogHandlers.py:1.6.14.2   Thu Oct  2 16:25:53 2003
+++ Packages/zLOG/LogHandlers.pyTue Apr 12 22:59:36 2005
@@ -13,11 +13,13 @@
 """Handlers which can plug into a PEP 282 logger."""
 
 import sys
+import os
 
 from logging import Handler, StreamHandler
 from logging.handlers import SysLogHandler
 from logging.handlers import HTTPHandler, SMTPHandler
 from logging.handlers import NTEventLogHandler as Win32EventLogHandler
+import zLOG
 
 class FileHandler(StreamHandler):
 """
@@ -35,6 +37,42 @@
 def reopen(self):
 self.close()
 self.stream = open(self.baseFilename, self.mode)
+
+class Win32FileHandler(FileHandler):
+"""File-based log handler for Windows that supports an additional 'rotate'
+method.  reopen() is generally useless since Windows cannot do a move on
+an open file.
+"""
+def rotate(self, rotateFilename=None):
+if not rotateFilename:
+rotateFilename = self.baseFilename + ".last"
+error = None
+self.close()
+try:
+os.rename(self.baseFilename, rotateFilename)
+except OSError, error:
+# logger cannot be used until we get a file handle again, so we
+# store it in 'error'
+pass
+
+self.stream = open(self.baseFilename, self.mode)
+
+if error:
+# Note we *expect* to see a "file exists" error if some external 
+# process has not cleaned up these logs.  For now, that just gets
+# logged like any other error.
+zLOG.LOG("Win32FileLogger", zLOG.ERROR,
+ "File rotation error moving '%s' to '%s':" %
+   (self.baseFilename, rotateFilename), error)
+else:
+zLOG.LOG("Win32FileLogger", zLOG.INFO,
+ "File rotation moved '%s' to '%s'" %
+   (self.baseFilename, rotateFilename))
+
+if os.name == "nt":
+# Make it the default for Windows - we install a 'reopen' handler that
+# tries to rotate the logfile.
+FileHandler = Win32FileHandler
 
 class NullHandler(Handler):
 """

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Packages/ZEO - component.xml:1.4.6.1 mkzeoinst.py:1.18.8.4 runzeo.py:1.15.6.5

2005-04-12 Thread Sidnei da Silva
Update of /cvs-repository/Packages/ZEO
In directory cvs.zope.org:/tmp/cvs-serv13625

Modified Files:
  Tag: Zope-2_7-branch
component.xml mkzeoinst.py runzeo.py 
Log Message:

* Borrow Zope's 'Signal' mechanism for Windows, if available, to
  implement clean shutdown and log rotation handlers for Windows.
* Back to creating a .PID for ZEO, so external programs that wish to set
  the 'signal' can get the PID and therefore derive the signal name.
  Currently only necessary on Windows but created on all platforms which
  implement os.getpid(), as long as the 'pid-filename' option is set,
  or the 'INSTANCE_HOME' environment variable can be found.


=== Packages/ZEO/component.xml 1.4 => 1.4.6.1 ===
--- Packages/ZEO/component.xml:1.4  Fri May 30 15:20:57 2003
+++ Packages/ZEO/component.xml  Tue Apr 12 22:54:54 2005
@@ -93,6 +93,15 @@
   
 
 
+
+  
+The full path to the file in which to write the ZEO server's Process ID
+at startup. If omitted, $INSTANCE/var/ZEO.pid is used.
+  
+  $INSTANCE/var/ZEO.pid (or $clienthome/ZEO.pid)
+
+
   
 
 


=== Packages/ZEO/mkzeoinst.py 1.18.8.3 => 1.18.8.4 ===
--- Packages/ZEO/mkzeoinst.py:1.18.8.3  Wed Feb 18 17:10:14 2004
+++ Packages/ZEO/mkzeoinst.py   Tue Apr 12 22:54:54 2005
@@ -47,6 +47,7 @@
   address %(port)d
   read-only false
   invalidation-queue-size 100
+  # pid-filename $INSTANCE/var/ZEO.pid
   # monitor-address PORT
   # transaction-timeout SECONDS
 


=== Packages/ZEO/runzeo.py 1.15.6.4 => 1.15.6.5 ===
--- Packages/ZEO/runzeo.py:1.15.6.4 Wed Jan 14 14:07:00 2004
+++ Packages/ZEO/runzeo.py  Tue Apr 12 22:54:54 2005
@@ -48,6 +48,11 @@
 obj = ZConfig.datatypes.SocketAddress(arg)
 return obj.family, obj.address
 
+def windows_shutdown_handler():
+# Called by the signal mechanism on Windows to perform shutdown.
+import asyncore
+asyncore.close_all()
+
 class ZEOOptionsMixin:
 
 storages = None
@@ -95,6 +100,8 @@
  None, 'auth-database=')
 self.add('auth_realm', 'zeo.authentication_realm',
  None, 'auth-realm=')
+self.add('pid_file', 'zeo.pid_filename',
+ None, 'pid-file=')
 
 class ZEOOptions(ZDOptions, ZEOOptionsMixin):
 
@@ -117,6 +124,7 @@
 self.setup_default_logging()
 self.check_socket()
 self.clear_socket()
+self.make_pidfile()
 try:
 self.open_storages()
 self.setup_signals()
@@ -125,6 +133,7 @@
 finally:
 self.close_storages()
 self.clear_socket()
+self.remove_pidfile()
 
 def setup_default_logging(self):
 if self.options.config_logger is not None:
@@ -175,6 +184,8 @@
 method is called without additional arguments.
 """
 if os.name != "posix":
+if os.name == "nt":
+self.setup_win32_signals()
 return
 if hasattr(signal, 'SIGXFSZ'):
 signal.signal(signal.SIGXFSZ, signal.SIG_IGN) # Special case
@@ -186,6 +197,27 @@
 method()
 signal.signal(sig, wrapper)
 
+def setup_win32_signals(self):
+# Borrow the Zope Signals package win32 support, if available.
+# Signals does a check/log for the availability of pywin32.
+try:
+import Signals.Signals
+except ImportError:
+debug("Signals package not found. "
+  "Windows-specific signal handler "
+  "will *not* be installed.")
+return
+SignalHandler = Signals.Signals.SignalHandler
+if SignalHandler is not None: # may be None if no pywin32.
+SignalHandler.registerHandler(signal.SIGTERM,
+  windows_shutdown_handler)
+SignalHandler.registerHandler(signal.SIGINT,
+  windows_shutdown_handler)
+# Can use the log rotate handler too.
+from Signals.Signals import logfileRotateHandler
+SIGUSR2 = 12 # not in signal module on Windows.
+SignalHandler.registerHandler(SIGUSR2, logfileRotateHandler)
+
 def create_server(self):
 from ZEO.StorageServer import StorageServer
 self.server = StorageServer(
@@ -232,6 +264,53 @@
 except: # Keep going
 exception("failed to close storage %r" % name)
 
+def _get_pidfile(self):
+pidfile = self.options.pid_file
+# 'pidfile' is marked as not required.
+if not pidfile:
+# Try to find a reasonable location if the pidfile is not
+# set. If we are running in a Zope environment, we can
+# safely assume INSTANCE_HOME.
+instance_home = os.environ.get("INSTANCE_HOME")
+if not instance_home:
+# If all our attempts failed, just log a message and
+# proceed.
+debug("'pidfile' opt

[Zope-Checkins] CVS: Packages/ZEO - __init__.py:1.19.4.20 version.txt:1.9.4.19

2005-04-12 Thread Tim Peters
Update of /cvs-repository/Packages/ZEO
In directory cvs.zope.org:/tmp/cvs-serv17156/ZEO

Modified Files:
  Tag: Zope-2_7-branch
__init__.py version.txt 
Log Message:
An "internal" 3.2.7c1 release, to get a critical BTree fix into Zope 3.2.6b1.


=== Packages/ZEO/__init__.py 1.19.4.19 => 1.19.4.20 ===
--- Packages/ZEO/__init__.py:1.19.4.19  Mon Mar  7 17:45:29 2005
+++ Packages/ZEO/__init__.pyTue Apr 12 18:23:14 2005
@@ -21,4 +21,4 @@
 
 """
 
-version = "2.2.6"
+version = "2.2.7c1"


=== Packages/ZEO/version.txt 1.9.4.18 => 1.9.4.19 ===
--- Packages/ZEO/version.txt:1.9.4.18   Mon Mar  7 17:45:29 2005
+++ Packages/ZEO/version.txtTue Apr 12 18:23:14 2005
@@ -1 +1 @@
-2.2.6
+2.2.7c1

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] CVS: Packages/ZODB - __init__.py:1.23.4.20

2005-04-12 Thread Tim Peters
Update of /cvs-repository/Packages/ZODB
In directory cvs.zope.org:/tmp/cvs-serv17156/ZODB

Modified Files:
  Tag: Zope-2_7-branch
__init__.py 
Log Message:
An "internal" 3.2.7c1 release, to get a critical BTree fix into Zope 3.2.6b1.


=== Packages/ZODB/__init__.py 1.23.4.19 => 1.23.4.20 ===
--- Packages/ZODB/__init__.py:1.23.4.19 Mon Mar  7 17:45:29 2005
+++ Packages/ZODB/__init__.py   Tue Apr 12 18:23:15 2005
@@ -13,7 +13,7 @@
 ##
 
 # Must use double quotes, so that release.py recognizes next line.
-__version__ = "3.2.6"
+__version__ = "3.2.7c1"
 
 import sys
 import cPersistence, Persistence

___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/Five/ set svn:eol-style

2005-04-12 Thread Yvo Schubbe
Log message for revision 29950:
  set svn:eol-style

Changed:
  _U  Zope/trunk/lib/python/Products/Five/CHANGES.txt
  _U  Zope/trunk/lib/python/Products/Five/CREDITS.txt
  _U  Zope/trunk/lib/python/Products/Five/README.txt
  _U  Zope/trunk/lib/python/Products/Five/ReuseUtils.py
  _U  Zope/trunk/lib/python/Products/Five/TODO.txt
  _U  Zope/trunk/lib/python/Products/Five/TrustedExpression.py
  _U  Zope/trunk/lib/python/Products/Five/__init__.py
  _U  Zope/trunk/lib/python/Products/Five/add.pt
  _U  Zope/trunk/lib/python/Products/Five/adding.pt
  _U  Zope/trunk/lib/python/Products/Five/adding.py
  _U  Zope/trunk/lib/python/Products/Five/api.py
  _U  Zope/trunk/lib/python/Products/Five/bridge.py
  _U  Zope/trunk/lib/python/Products/Five/browser.py
  _U  Zope/trunk/lib/python/Products/Five/browserconfigure.py
  _U  Zope/trunk/lib/python/Products/Five/configure.zcml
  _U  Zope/trunk/lib/python/Products/Five/doc/directives.txt
  _U  Zope/trunk/lib/python/Products/Five/doc/features.txt
  _U  Zope/trunk/lib/python/Products/Five/doc/main.txt
  _U  Zope/trunk/lib/python/Products/Five/doc/manual.txt
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/FiveMiscTutorial/__init__.py
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/FiveMiscTutorial/configure.zcml
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/InterfaceTutorial/__init__.py
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/InterfaceTutorial/configure.zcml
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/InterfaceTutorial/module.py
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/InterfaceTutorial/other.py
  _U  Zope/trunk/lib/python/Products/Five/doc/products/README.txt
  _U  Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/__init__.py
  _U  Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/browser.py
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/configure.zcml
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/democontent.py
  _U  Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/one.pt
  _U  Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/overview.pt
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/overview2.pt
  _U  Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/someview.pt
  _U  
Zope/trunk/lib/python/Products/Five/doc/products/ViewsTutorial/www/demoContentAdd.zpt
  _U  Zope/trunk/lib/python/Products/Five/edit.pt
  _U  Zope/trunk/lib/python/Products/Five/eventconfigure.py
  _U  Zope/trunk/lib/python/Products/Five/five_template.pt
  _U  Zope/trunk/lib/python/Products/Five/fiveconfigure.py
  _U  Zope/trunk/lib/python/Products/Five/fivedirectives.py
  _U  Zope/trunk/lib/python/Products/Five/interfaces.py
  _U  Zope/trunk/lib/python/Products/Five/interfaces.zcml
  _U  Zope/trunk/lib/python/Products/Five/makefile.in
  _U  Zope/trunk/lib/python/Products/Five/meta.zcml
  _U  Zope/trunk/lib/python/Products/Five/metaclass.py
  _U  Zope/trunk/lib/python/Products/Five/metaconfigure.py
  _U  Zope/trunk/lib/python/Products/Five/pagetemplatefile.py
  _U  Zope/trunk/lib/python/Products/Five/permissions.zcml
  _U  Zope/trunk/lib/python/Products/Five/resource.py
  _U  Zope/trunk/lib/python/Products/Five/security.py
  _U  Zope/trunk/lib/python/Products/Five/services.zcml
  _U  Zope/trunk/lib/python/Products/Five/skel/README.txt
  _U  Zope/trunk/lib/python/Products/Five/skel/site.zcml
  _U  Zope/trunk/lib/python/Products/Five/tests/README.txt
  _U  Zope/trunk/lib/python/Products/Five/tests/__init__.py
  _U  Zope/trunk/lib/python/Products/Five/tests/dummy.py
  _U  Zope/trunk/lib/python/Products/Five/tests/fivetest.py
  _U  Zope/trunk/lib/python/Products/Five/tests/framework.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/__init__.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/bird.pt
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/browser.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/classes.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/cockatiel.pt
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/condor.pt
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/configure.zcml
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/dog.pt
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/falcon.pt
  _U  
Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/fancycontent.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/flamingo.pt
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/flamingo2.pt
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/helpers.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/interfaces.py
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/meta.zcml
  _U  Zope/trunk/lib/python/Products/Five/tests/products/FiveTest/ostrich.pt
  _U  Zo