Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install hatch

How to install hatch

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install hatch
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.9 Available View build log
0.8 Available View build log
Windows (64-bit)
0.9 Available View build log
0.8 Available View build log
Mac OS X (10.5+)
0.9 Available View build log
0.8 Available View build log
Linux (32-bit)
0.9 Available View build log
0.8 Available View build log
Linux (64-bit)
0.9 Available View build log
0.8 Available View build log
 
Author
License
MIT/X11
Dependencies
Imports
Lastest release
version 0.9 on Jan 9th, 2012

Hatch is an easy to use framework for loading extensions into Python applications. No really, it is:

import hatch

class DummyInterface(hatch.Interface):
    def method(self):
        pass

for instance in DummyInterace.instances():
    # Loop through all implementations of the interface that were
    # found in plugins
    print instance.method()

Or you can take this code out for a spin in your interactive interpreter:

>>>import hatch
>>>class IObserve(hatch.Interface):
...    @classmethod
...    def notify(cls):
...        cls.apply('notify')
...
>>>class SnippyObserver(object):
...    def notify(self):
...        print "Doesn't hatch have a better way to do this?"
...
>>>class CleverObserver(object):
...    def notify(self):
...        print "That's not the point..."
...
>>>hatch.add_internal_extension('__main__.IObserve', SnippyObserver)
>>>hatch.add_internal_extension('__main__.IObserve', CleverObserver)
>>>IObserve.notify()
Doesn't hatch have a better way to do this?
That's not the point

For curious ones, the observer pattern is supported natively:

>>>import hatch
>>>def winded_observer(arg):
...    print "Hey, I was 'observing' and I got this message:", arg

>>>def quiet_observer(arg):
...    print arg

>>>hatch.add_internal_extension('observer_hook', winded_observer)
>>>hatch.add_internal_extension('observer_hook', quiet_observer)
>>>notify = hatch.Observers('observer_hook')
>>>notify('foo')
Hey, I was 'observing' and I got this message: foo
foo

How does it find extensions?

That's up to you. Hatch can load extensions from an internal source, a setuptools entry point, or any other source. Telling Hatch where to load extensions from is just as easy as everything else:

from hatch.entry_points import EpFinder

hatch.register_global_finder(EpFinder('/path/to/plugin/dir'))
# Or alternatively, to load plugins directly off sys.path:
hatch.register_global_finder(EpFinder())

Check out the Finders documentation for details on the different finders that you can use.

Got Questions?

You can contact me directly through xmpp (or email): te-je@geniphi.com. If you find a bug, use Github to file an issue (you'd really be helping me out).

Subscribe to package updates

Last updated Jan 9th, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.