ShellBanner
System:Linux MiraNet 3.0.0-14-generic-pae #23-Ubuntu SMP Mon Nov 21 22:07:10 UTC 2011 i686
Software:Apache. PHP/5.3.6-13ubuntu3.10
ID:uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
Safe Mode:OFF
Open_Basedir:OFF
Freespace:21.28 GB of 70.42 GB (30.22%)
MySQL: ON MSSQL: OFF Oracle: OFF PostgreSQL: OFF Curl: OFF Sockets: ON Fetch: OFF Wget: ON Perl: ON
Disabled Functions: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,

/ usr/ lib/ python2.6/ dist-packages/ zope/ interface/ - drwxr-xr-x

Directory:
Viewing file:     verify.txt (3.26 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
===================================
Verifying interface implementations
===================================

The ``zope.interface.verify`` module provides functions that test whether a
given interface is implemented by a class or provided by an object, resp.


Verifying classes
=================

This is covered by unit tests defined in ``zope.interface.tests.test_verify``.


Verifying objects
=================

An object provides an interface if

- either its class declares that it implements the interfaces, or the object
  declares that it directly provides the interface

- the object defines all the methods required by the interface

- all the methods have the correct signature

- the object defines all non-method attributes required by the interface

This doctest currently covers only the latter item.

Testing for attributes
----------------------

Attributes of the object, be they defined by its class or added by its
``__init__`` method, will be recognized:

>>> from zope.interface import Interface, Attribute, implements
>>> from zope.interface.exceptions import BrokenImplementation
>>> class IFoo(Interface):
...     x = Attribute("The X attribute")
...     y = Attribute("The Y attribute")

>>> class Foo(object):
...     implements(IFoo)
...     x = 1
...     def __init__(self):
...         self.y = 2

>>> from zope.interface.verify import verifyObject
>>> verifyObject(IFoo, Foo())
True

If either attribute is missing, verification will fail:

>>> class Foo(object):
...     implements(IFoo)
...     x = 1

>>> try: #doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
...     verifyObject(IFoo, Foo())
... except BrokenImplementation, e:
...     print str(e)
An object has failed to implement interface <InterfaceClass ...IFoo>
<BLANKLINE>
        The y attribute was not provided.
<BLANKLINE>

>>> class Foo(object):
...     implements(IFoo)
...     def __init__(self):
...         self.y = 2

>>> try: #doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
...     verifyObject(IFoo, Foo())
... except BrokenImplementation, e:
...     print str(e)
An object has failed to implement interface <InterfaceClass ...IFoo>
<BLANKLINE>
        The x attribute was not provided.
<BLANKLINE>

If an attribute is implemented as a property that raises an AttributeError
when trying to get its value, the attribute is considered missing:

>>> class IFoo(Interface):
...     x = Attribute('The X attribute')

>>> class Foo(object):
...     implements(IFoo)
...     @property
...     def x(self):
...         raise AttributeError

>>> try: #doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
...     verifyObject(IFoo, Foo())
... except BrokenImplementation, e:
...     print str(e)
An object has failed to implement interface <InterfaceClass ...IFoo>
<BLANKLINE>
        The x attribute was not provided.
<BLANKLINE>

Any other exception raised by a property will propagate to the caller of
``verifyObject``:

>>> class Foo(object):
...     implements(IFoo)
...     @property
...     def x(self):
...         raise Exception

>>> verifyObject(IFoo, Foo())
Traceback (most recent call last):
Exception

Of course, broken properties that are not required by the interface don't do
any harm:

>>> class Foo(object):
...     implements(IFoo)
...     x = 1
...     @property
...     def y(self):
...         raise Exception

>>> verifyObject(IFoo, Foo())
True
Command:
Quick Commands:
Upload:
[Read-Only] Max size: 100MB
PHP Filesystem: <@ Ú
Search File:
regexp
Create File:
Overwrite [Read-Only]
View File:
Mass Defacement:
[+] Main Directory: [+] Defacement Url:
LmfaoX Shell - Private Build [BETA] - v0.1 -; Generated: 0.2895 seconds