This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Loosely coupled, ABC based, Python Interface Registry

Project Description

🎭 About

visage is a small project providing a registry for loose coupling of interfaces and implementations.

visage is heavily based on Python’s abstract base classes for allowing isinstance checks in the presence of an interface definition. However, in the absence of an interface definition, registry-level checks can be performed in order to evaluate a given implementation’s declaration of interface support.

Sample usage:

import abc
import visage.lib

@visage.lib.interface('company.com/interface/Shapes')
class Interface(metaclass=abc.ABCMeta):
        pass

@visage.lib.implementation('company.com/interface/Shapes')
class Implementation(object):
        pass

Instance = Implementation()

assert visage.lib.isinstance(Instance, 'company.com/interface/Shapes')
assert visage.lib.hasinterface(Implementation, 'company.com/interface/Shapes')
assert visage.lib.isdefinition(Interface, 'company.com/interface/Shapes')

However, the declaration of the interface is not necessary for an implementation to be declared. Implementations are fully functional without an interface, and identifier based checks can be easily used.

When the Interface object is present, it can be used to do checks using the builtins that work with classes:

assert isinstance(Instance, Interface)
assert issubclass(Implementation, Interface)

Future

  • Registry Queries for Selecting Implementation classes based on quals.
  • IID-to-module mappings for IID based imports.
  • Adaption capabilities?
Release History

Release History

This version
History Node

0.3.0

History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
visage-0.3.0.tar.gz (11.7 kB) Copy SHA256 Checksum SHA256 – Source Aug 12, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting