Source code for pyams_scheduler.interfaces.url

#
# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#

__docformat__ = 'restructuredtext'


# import standard library
from urllib import parse

# import interfaces
from pyams_scheduler.interfaces import ITask

# import packages
from zope.interface import invariant, Interface, Invalid
from zope.schema import URI, TextLine, Bool, Password, Int

from pyams_scheduler import _


[docs]class IURLCallerTaskInfo(Interface): """URL caller task info""" url = URI(title=_("Target URI"), description=_("Full URI of remote service"), required=True) username = TextLine(title=_("User name"), description=_("Target login"), required=False) password = Password(title=_("Password"), description=_("Target password"), required=False) proxy_server = TextLine(title=_("Proxy server"), description=_("Proxy server name"), required=False) proxy_port = Int(title=_("Proxy port"), description=_("Proxy server port"), required=False, default=8080) remote_dns = Bool(title=_("Use remote DNS ?"), description=_("If 'Yes', remote DNS queries will be done by proxy server"), required=True, default=True) proxy_username = TextLine(title=_("Proxy user name"), required=False) proxy_password = Password(title=_("Proxy password"), required=False) connection_timeout = Int(title=_("Connection timeout"), description=_("Connection timeout, in seconds; keep empty to use system's " "default, which is also none by default"), required=False, default=30) @invariant def check_hostname(self): parser = parse.urlparse(self.url) if not parser.netloc: raise Invalid(_("Missing hostname!")) @invariant def check_proxy(self): if self.proxy_server and not self.proxy_port: raise Invalid(_("Proxy server defined without proxy port!"))
[docs]class IURLCallerTask(ITask, IURLCallerTaskInfo): """URL caller interface"""