Changeset 337

Show
Ignore:
Timestamp:
08/28/06 22:36:20 (2 years ago)
Author:
mj
Message:

Disable autostart when not in debug mode or when allowing remote attachment

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • z3wingdbg/trunk/TODO.txt

    r336 r337  
    88- Use custom permissions 
    99- Implement auto-reconnect (YAGNI?) 
    10 - Disable auto-start when not in debug mode 
    11 - Disable auto-start when attaching is allowed 
    1210 
    1311Debugger package 
  • z3wingdbg/trunk/wingdebugservice.py

    r297 r337  
    22# This program is open source.  For license terms, see the LICENSE.txt file. 
    33 
     4import logging 
    45import time 
    56 
     
    89from zope.i18n import MessageFactory 
    910 
     11from zope.app.appsetup.appsetup import getConfigContext 
    1012from zope.app.component.hooks import getSite 
    1113from zope.app.publication.zopepublication import ZopePublication 
     
    129131    root = connection.root() 
    130132    root_folder = root.get(ZopePublication.root_name, None) 
    131  
    132     if root_folder is None: 
    133         connection.close() 
    134         return 
     133    log = logging.getLogger('z3wingdbg.wingdebugservice') 
    135134     
    136     config = component.queryUtility(IWingConfiguration, context=root_folder) 
    137     if config and config.autoStart: 
     135    try: 
     136        if root_folder is None: 
     137            return 
     138         
     139        debugmode = getConfigContext().hasFeature('devmode') 
     140        if not debugmode: 
     141            return 
     142         
     143        config = component.queryUtility(IWingConfiguration,  
     144                                        context=root_folder) 
     145        if not config: 
     146            return 
     147         
     148        if not config.autoStart: 
     149            return 
     150         
     151        if config.attachPort is not None: 
     152            log.warn('Not autostarting the wing debug server when allowing ' 
     153                     'remote connections.') 
     154            return 
     155         
    138156        service = component.getUtility(IWingDebugService) 
    139157        try: 
    140             try: 
    141                 service.startDebugServer(context=root_folder) 
    142             except (DebugServerStartError, IDEConnectionError): 
    143                 pass 
    144         finally: 
    145             connection.close() 
    146     else: 
     158            service.startDebugServer(context=root_folder) 
     159        except (DebugServerStartError, IDEConnectionError): 
     160            pass 
     161    finally: 
    147162        connection.close()