##// END OF EJS Templates
More work addressing review comments for Fernando's branch....
More work addressing review comments for Fernando's branch. * :mod:`IPython.testing.globalipapp` now directly creates a :class:`~IPython.core.iplib.InteractiveShell` instance by passing it a configuration object, rather than creating an IPython application. * Updated everything in :mod:`IPython.frontend` and :mod:`IPython.gui` to use raw :class:`~IPython.core.iplib.InteractiveShell directly rather than creating an IPython application. * Updated the IPython sphinx extension to use raw :class:`~IPython.core.iplib.InteractiveShell directly rather than creating an IPython application. * Removed code from :mod:`IPython.extensions.pretty` that called :func:`get_ipython` (r1271). * Addressed comment on (r1284) about holding refs to deferreds in :mod:`IPython.kernel.ipclusterapp`. * Removed :mod:`IPython.kernel` from list of modules tested by nose in :mod:`IPython.testing.iptest`. (r1318)

File last commit:

r2301:649f9975
r2499:58bf4021
Show More
configobjfactory.py
78 lines | 2.4 KiB | text/x-python | PythonLexer
#!/usr/bin/env python
# encoding: utf-8
"""
A class for creating a Twisted service that is configured using IPython's
configuration system.
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2008-2009 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import zope.interface as zi
from IPython.core.component import Component
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
class IConfiguredObjectFactory(zi.Interface):
"""I am a component that creates a configured object.
This class is useful if you want to configure a class that is not a
subclass of :class:`IPython.core.component.Component`.
"""
def __init__(config):
"""Get ready to configure the object using config."""
def create():
"""Return an instance of the configured object."""
class ConfiguredObjectFactory(Component):
zi.implements(IConfiguredObjectFactory)
def __init__(self, config):
super(ConfiguredObjectFactory, self).__init__(None, config=config)
def create(self):
raise NotImplementedError('create must be implemented in a subclass')
class IAdaptedConfiguredObjectFactory(zi.Interface):
"""I am a component that adapts and configures an object.
This class is useful if you have the adapt an instance and configure it.
"""
def __init__(config, adaptee=None):
"""Get ready to adapt adaptee and then configure it using config."""
def create():
"""Return an instance of the adapted and configured object."""
class AdaptedConfiguredObjectFactory(Component):
# zi.implements(IAdaptedConfiguredObjectFactory)
def __init__(self, config, adaptee):
# print
# print "config pre:", config
super(AdaptedConfiguredObjectFactory, self).__init__(None, config=config)
# print
# print "config post:", config
self.adaptee = adaptee
def create(self):
raise NotImplementedError('create must be implemented in a subclass')