This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

About

A simple plugin framework inspired by the work of Marty Alchin.

Continuous integration is powered by Jenkins.

Installation

To install simple_plugins run:

$ pip install simple_plugins

Usage examples

Quick start:

>>> from simple_plugins import PluginMount

>>> class BaseHttpResponse(object):
...     """Mount point is not registered as a plugin"""
...
...     status_code = None
...
...     __metaclass__ = PluginMount
...
...     class Meta:
...         id_field = 'status_code'
...
...     def __repr__(self):
...         return "<%s: %s>" % (self.__class__.__name__, self.status_code)
...

>>> class OK(BaseHttpResponse):
...     status_code = 200
...

>>> class BaseRedirection(BaseHttpResponse):
...     """'Base*' classes are not registered as plugins"""
...     pass
...

>>> class MovedPermanently(BaseRedirection):
...     status_code = 301
...

>>> class NotModified(BaseRedirection):
...     status_code = 304
...

>>> class BadRequest(BaseHttpResponse):
...     status_code = 400
...

>>> class NotFound(BaseHttpResponse):
...     status_code = 404
...

# All plugin info
>>> BaseHttpResponse.plugins.keys()
['valid_ids', 'instances_sorted_by_id', 'id_to_class', 'instances',
 'classes', 'class_to_id', 'id_to_instance']

# Plugin info can be accessed using either dict...
>>> BaseHttpResponse.plugins['valid_ids']
set([304, 400, 404, 200, 301])

# ... or object notation
>>> BaseHttpResponse.plugins.valid_ids
set([304, 400, 404, 200, 301])

>>> BaseHttpResponse.plugins.classes
set([<class '__main__.NotFound'>, <class '__main__.OK'>,
     <class '__main__.NotModified'>, <class '__main__.BadRequest'>,
     <class '__main__.MovedPermanently'>])

>>> BaseHttpResponse.plugins.id_to_class[200]
<class '__main__.OK'>

>>> BaseHttpResponse.plugins.id_to_instance[200]
<OK: 200>

>>> BaseHttpResponse.plugins.instances_sorted_by_id
[<OK: 200>, <MovedPermanently: 301>, <NotModified: 304>, <BadRequest: 400>, <NotFound: 404>]

# Unregister the `NotFound` plugin
>>> NotFound._unregister_plugin()
>>> BaseHttpResponse.plugins.instances_sorted_by_id
[<OK: 200>, <MovedPermanently: 301>, <NotModified: 304>, <BadRequest: 400>]

# Coerce the passed value into the right instance
>>> BaseHttpResponse.coerce(200)
<OK: 200>

Please see the tests, beam_integrals and splatex source code for more examples.

Contribute

If you find any bugs, or wish to propose new features please let me know.

If you’d like to contribute, simply fork the repository, commit your changes and send a pull request. Make sure you add yourself to AUTHORS.

Release History

Release History

1.0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
simple_plugins-1.0.1.zip (16.4 kB) Copy SHA256 Checksum SHA256 Source Sep 30, 2013

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