Changeset 340

Show
Ignore:
Timestamp:
09/01/06 12:34:08 (2 years ago)
Author:
mj
Message:

Specify attachment password source options, and invariants

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • z3wingdbg/trunk/interfaces.py

    r325 r340  
    9797        """Run code in the debugger context""" 
    9898         
    99      
     99# Attachment password source types     
     100PWD_PROFILE, PWD_PATH, PWD_MANUAL = range(3) 
     101 
    100102# Configuration of the service and debug server 
    101103class IWingConfiguration(interface.Interface): 
     
    135137        title=_(u'Auto-start debug server'), 
    136138        description=_(u'auto-start-description', 
    137                       u'Automatically start the debug server when Zope starts'), 
     139                      u'Automatically start the debug server when Zope starts ' 
     140                      u'and is running in Developer Mode.'), 
    138141        default=False) 
    139142     
     
    155158        required=False) 
    156159     
     160    @interface.invariant 
     161    def noAutoStartAndAttachPort(obj): 
     162        """Cannot specify both auto-starting and an attachment port""" 
     163        if obj.autoStart and (obj.attachPort is not None): 
     164            raise interface.Invalid( 
     165                _(u'Cannot specify both auto-start and an attachment port')) 
     166     
     167    attachPasswordSource = schema.Choice( 
     168        title=_(u'Password source'), 
     169        description=_(u'attach-password-source-description', 
     170                      u'Where to source the password information for the ' 
     171                      u'attaching IDE'), 
     172        vocabulary=schema.vocabulary.SimpleVocabulary.fromItems(( 
     173            (_(u'Wing Profile Directory'), PWD_PROFILE), 
     174            (_(u'Specified path'),         PWD_PATH), 
     175            (_(u'Specified password'),     PWD_MANUAL))), 
     176        default=PWD_PROFILE) 
     177     
     178    attachPasswordPath = schema.TextLine( 
     179        title=_(u'Password source path'), 
     180        description=_(u'attach-password-path-description', 
     181                      u'The path to a password source file. Can be both a ' 
     182                      u'file as well as a directory path; in the latter case ' 
     183                      u'the file .wingdebugpw in that directory will be ' 
     184                      u'used.'), 
     185        required=False) 
     186     
     187    attachPassword = schema.BytesLine( 
     188        title=_(u'Attach password'), 
     189        description=_(u'attach-password-description', 
     190                      u'Password to be supplied by attaching IDE'), 
     191        required=False) 
     192     
     193    @interface.invariant 
     194    def checkAttachPassword(obj): 
     195        """If source is not PWD_PROFILE, the source needs to be specified""" 
     196        if obj.attachPasswordSource == PWD_PATH: 
     197            if not obj.attachPasswordPath: 
     198                raise interface.Invalid( 
     199                    _(u'Please specify the path of the password source')) 
     200        elif obj.attachPasswordSource == PWD_MANUAL: 
     201            if not obj.attachPassword: 
     202                raise interface.Invalid( 
     203                    _(u'Please specify an attach password')) 
     204     
    157205class IDebugServerConfiguration(interface.Interface): 
    158206    """Debug server configuration"""