src/pyams_utils/interfaces/zeo.py
changeset 10 e87103c49c8a
child 134 73c01f34ef19
equal deleted inserted replaced
9:6a55c8cbced0 10:e87103c49c8a
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 
       
    20 # import packages
       
    21 from zope.interface import Interface, Attribute
       
    22 from zope.schema import TextLine, Int, Password, Bool
       
    23 
       
    24 from pyams_utils import _
       
    25 
       
    26 
       
    27 class IZEOConnection(Interface):
       
    28     """ZEO connection settings interface"""
       
    29 
       
    30     name = TextLine(title=_("Connection name"),
       
    31                     description=_("Registration name of ZEO connection"),
       
    32                     required=True)
       
    33 
       
    34     server_name = TextLine(title=_("ZEO server name"),
       
    35                            description=_("Hostname of ZEO server"),
       
    36                            required=True,
       
    37                            default='localhost')
       
    38 
       
    39     server_port = Int(title=_("ZEO server port"),
       
    40                       description=_("Port number of ZEO server"),
       
    41                       required=True,
       
    42                       default=8100)
       
    43 
       
    44     storage = TextLine(title=_("ZEO server storage"),
       
    45                        description=_("Storage name on ZEO server"),
       
    46                        required=True,
       
    47                        default='1')
       
    48 
       
    49     username = TextLine(title=_("ZEO user name"),
       
    50                         description=_("User name on ZEO server"),
       
    51                         required=False)
       
    52 
       
    53     password = Password(title=_("ZEO password"),
       
    54                         description=_("User password on ZEO server"),
       
    55                         required=False)
       
    56 
       
    57     server_realm = TextLine(title=_("ZEO server realm"),
       
    58                             description=_("Realm name on ZEO server"),
       
    59                             required=False)
       
    60 
       
    61     blob_dir = TextLine(title=_("BLOBs directory"),
       
    62                         description=_("Directory path for blob data"),
       
    63                         required=False)
       
    64 
       
    65     shared_blob_dir = Bool(title=_("Shared BLOBs directory ?"),
       
    66                            description=_("""Flag whether the blob_dir is a server-shared filesystem """
       
    67                                          """that should be used instead of transferring blob data over zrpc."""),
       
    68                            required=True,
       
    69                            default=False)
       
    70 
       
    71     connection = Attribute(_("Opened ZEO connection"))
       
    72 
       
    73     def get_settings(self):
       
    74         """Get ZEO connection setting as a JSON dict"""
       
    75 
       
    76     def update(self, settings):
       
    77         """Update internal fields with given settings dict"""
       
    78 
       
    79     def get_connection(self, wait=False, get_storage=False):
       
    80         """Open ZEO connection with given settings"""