Exemple #1
0
    def commands(self):
        ret = []

        try:
            commands = package_contents("%s.commands" % (self.package_name,), filter_function=lambda name: name.startswith("_"))
        except ImportError:
            return ret

        for command in commands:
            class_name = "%sCommand" % (camelize(command))
            _, cmdclass = import_object("%s.commands.%s.%s" % (self.package_name, command, class_name))
            ret.append(cmdclass())

        return ret
Exemple #2
0
 def _import_settings(self, path):
     try:
         _, settings = import_object("%s.SETTINGS" % (path,))
     except ImportError, ex:
         raise SettingsError("Error importing %s.SETTINGS (%s)" % (path, ex))
Exemple #3
0
 def routes(self):
     urlpatterns = "%s.routes.routes" % (self.package_name,)
     try:
         _, routes = import_object(urlpatterns)
     except ImportError, ex:
         raise ApplicationError("Error reading routing table from %s: %s" % (urlpatterns, ex))
 def test_import_object(self):
     module, imported_object = import_object("forecast.tests.settings.base.SETTINGS")
     self.assertTrue(repr(module).startswith("<module 'forecast.tests.settings.base' from"))
     self.assertIsInstance(imported_object, dict)