##// END OF EJS Templates
Merge branch 'master' of github.com:ellisonbg/ipython into newkernel
Merge branch 'master' of github.com:ellisonbg/ipython into newkernel

File last commit:

r2768:3991b816
r2769:764fc61d merge
Show More
configobjfactory.py
79 lines | 2.5 KiB | text/x-python | PythonLexer
/ IPython / kernel / configobjfactory.py
Brian Granger
Continuing work on ipcontroller.
r2288 #!/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
Brian Granger
First draft of refactored Component->Configurable.
r2731 from IPython.config.configurable import Configurable
Brian Granger
Continuing work on ipcontroller.
r2288
#-----------------------------------------------------------------------------
# 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
Brian Granger
First draft of refactored Component->Configurable.
r2731 subclass of :class:`IPython.config.configurable.Configurable`.
Brian Granger
Continuing work on ipcontroller.
r2288 """
Brian Granger
Fixing small bugs in ipcluster stuff....
r2768 def __init__(config=None):
Brian Granger
Continuing work on ipcontroller.
r2288 """Get ready to configure the object using config."""
def create():
"""Return an instance of the configured object."""
Brian Granger
First draft of refactored Component->Configurable.
r2731 class ConfiguredObjectFactory(Configurable):
Brian Granger
Continuing work on ipcontroller.
r2288
zi.implements(IConfiguredObjectFactory)
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 def __init__(self, config=None):
Brian Granger
First draft of refactored Component->Configurable.
r2731 super(ConfiguredObjectFactory, self).__init__(config=config)
Brian Granger
Continuing work on ipcontroller.
r2288
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.
Brian Granger
ipcontroller/ipengine use the new clusterdir.py module.
r2301 This class is useful if you have the adapt an instance and configure it.
Brian Granger
Continuing work on ipcontroller.
r2288 """
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 def __init__(config=None, adaptee=None):
Brian Granger
Continuing work on ipcontroller.
r2288 """Get ready to adapt adaptee and then configure it using config."""
def create():
"""Return an instance of the adapted and configured object."""
Brian Granger
First draft of refactored Component->Configurable.
r2731 class AdaptedConfiguredObjectFactory(Configurable):
Brian Granger
Continuing work on ipcontroller.
r2288
# zi.implements(IAdaptedConfiguredObjectFactory)
Brian Granger
Adding support for HasTraits to take keyword arguments.
r2740 def __init__(self, config=None, adaptee=None):
Brian Granger
Finished refactoring ipcontroller to be a proper application....
r2297 # print
# print "config pre:", config
Brian Granger
First draft of refactored Component->Configurable.
r2731 super(AdaptedConfiguredObjectFactory, self).__init__(config=config)
Brian Granger
Finished refactoring ipcontroller to be a proper application....
r2297 # print
# print "config post:", config
Brian Granger
Continuing work on ipcontroller.
r2288 self.adaptee = adaptee
def create(self):
Brian Granger
First draft of refactored Component->Configurable.
r2731 raise NotImplementedError('create must be implemented in a subclass')