src/ztfy/utils/interfaces.py
branchZTK-1.1
changeset 277 35f11f1758e9
parent 233 6c087119379d
equal deleted inserted replaced
276:6b7e4b7b6efe 277:35f11f1758e9
    21 from zope.component.interfaces import IObjectEvent
    21 from zope.component.interfaces import IObjectEvent
    22 
    22 
    23 # import local interfaces
    23 # import local interfaces
    24 
    24 
    25 # import Zope3 packages
    25 # import Zope3 packages
    26 from zope.interface import Interface, Attribute
    26 from zope.interface import invariant, Interface, Invalid, Attribute
    27 from zope.schema import TextLine, Int, Password, Bool
    27 from zope.schema import TextLine, Int, Password, Bool
    28 
    28 
    29 # import local packages
    29 # import local packages
    30 
    30 
    31 from ztfy.utils import _
    31 from ztfy.utils import _
   298 #
   298 #
   299 
   299 
   300 class IZEOConnection(Interface):
   300 class IZEOConnection(Interface):
   301     """ZEO connection settings interface"""
   301     """ZEO connection settings interface"""
   302 
   302 
       
   303     config_path = TextLine(title=_("ZODB configuration path"),
       
   304                            description=_("Absolute path to ZODB configuration file"),
       
   305                            required=False)
       
   306 
   303     server_name = TextLine(title=_("ZEO server name"),
   307     server_name = TextLine(title=_("ZEO server name"),
   304                            description=_("Hostname of ZEO server"),
   308                            description=_("Hostname of ZEO server"),
   305                            required=True,
   309                            required=False,
   306                            default=u'localhost')
   310                            default=u'localhost')
   307 
   311 
   308     server_port = Int(title=_("ZEO server port"),
   312     server_port = Int(title=_("ZEO server port"),
   309                       description=_("Port number of ZEO server"),
   313                       description=_("Port number of ZEO server"),
   310                       required=True,
   314                       required=False,
   311                       default=8100)
   315                       default=8100)
   312 
   316 
   313     storage = TextLine(title=_("ZEO server storage"),
   317     storage = TextLine(title=_("ZEO server storage"),
   314                        description=_("Storage name on ZEO server"),
   318                        description=_("Storage name on ZEO server"),
   315                        required=True,
   319                        required=False,
   316                        default=u'1')
   320                        default=u'1')
       
   321 
       
   322     @invariant
       
   323     def check_configuration(self):
       
   324         if not (self.config_path or self.server_name):
       
   325             raise Invalid(_("You must define configuration path or hostname"))
   317 
   326 
   318     username = TextLine(title=_("ZEO user name"),
   327     username = TextLine(title=_("ZEO user name"),
   319                         description=_("User name on ZEO server"),
   328                         description=_("User name on ZEO server"),
   320                         required=False)
   329                         required=False)
   321 
   330