Permalink
Browse files

Merge branch 'master' of github.com:kurtiss/shrapnel

  • Loading branch information...
kurtiss committed Aug 14, 2010
2 parents 556a9de + be6a8e1 commit 5a626f04dda2b85714b0c370ac2933bdcb1e3486
Showing with 16 additions and 0 deletions.
  1. +16 −0 shrapnel/config.py
View
@@ -25,6 +25,13 @@ def instance(name, *args, **kwargs):
return MyProvider._instance.__provide__(method_name)
+def list_instances():
+ """
+ Return a list of all top-level instance names. This will not include any
+ specific configuration. For instance, only 'foo' will be included in the
+ list if 'foo', 'foo.bar', 'foo.baz', etc are valid.
+ """
+ return ProviderMetaclass._subclasses.keys()
class ProviderMetaclass(type):
_subclasses = {}
@@ -137,10 +144,19 @@ def __defaults__(self):
class MongoProvider(Provider):
__abstract__ = True
+ class DummyDB(object):
+ def __getattr__(self, name):
+ raise NotImplementedError
+
def __provide__(self, method_name):
from . import mongodb
config_method = getattr(self, method_name)
config = dict(self.__defaults__().items() + config_method().items())
+ if config.get('dummy', False):
+ from warnings import warn
+ warn("Using Dummy Mongodb. If you don't know what this means, disable the dummy option in your mongo settings.")
+ return self.DummyDB()
+
return mongodb.MongoHelper(method_name, config)
def __defaults__(self):

0 comments on commit 5a626f0

Please sign in to comment.