def zserverRunner(host, port, log=None): '''Runs an HTTP ZServer on host:port.''' from ZServer import logger, asyncore from ZServer import zhttp_server, zhttp_handler if log is None: log = dummyLOG lg = logger.file_logger(log) hs = zhttp_server(ip=host, port=port, resolver=None, logger_object=lg) zh = zhttp_handler(module='Zope2', uri_base='') hs.install_handler(zh) asyncore.loop()
raise # Handler for a published module. zhttp_handler takes 3 arguments: # The name of the module to publish, and optionally the URI base # which is basically the SCRIPT_NAME, and optionally a dictionary # with CGI environment variables which override default # settings. The URI base setting is useful when you want to # publish more than one module with the same HTTP server. The CGI # environment setting is useful when you want to proxy requests # from another web server to ZServer, and would like the CGI # environment to reflect the CGI environment of the other web # server. zh = zhttp_handler('Zope', '', {}) zh._force_connection_close = 1 hs.install_handler(zh) sys.ZServerExitCode=0 asyncore.loop() sys.exit(sys.ZServerExitCode) def populateFolder(folder, folder_type, doc_type): """ Creates a structure like: \index_html \doc1 \folder1 \folder11 \folder12 \doc11 \folder2 \folder21 \doc21 \index_html
pass except: raise # Check umask sanity if we're on posix. if os.name == 'posix' and not os.environ.get('Z_DEBUG_MODE'): # umask is silly, blame POSIX. We have to set it to get its value. current_umask = os.umask(0) os.umask(current_umask) if current_umask != 077: current_umask = '%03o' % current_umask zLOG.LOG("z2", zLOG.INFO, ( 'Your umask of %s may be too permissive; for the security of ' 'your Zope data, it is recommended you use 077' % current_umask )) except: # Log startup exception and tell zdaemon not to restart us. try: zLOG.LOG("z2", zLOG.PANIC, "Startup exception", error=sys.exc_info()) except: pass sys.exit(0) # Start Medusa, Ye Hass! Rand.load_file('%s/randpool.dat' % INSTANCE_HOME, -1) sys.ZServerExitCode=0 asyncore.loop() Rand.save_file('%s/randpool.dat' % INSTANCE_HOME) sys.exit(sys.ZServerExitCode)