Exemplo n.º 1
0
    def discover_models(self):
        """
        Return a dict containing a list of cqlengine.Model classes within
        installed App.
        """

        apps = get_installed_apps()
        for app in apps:
            self._cql_models[app.__name__] = get_cql_models(app)
Exemplo n.º 2
0
    def _discover_models(self):
        """
        Return a dict containing a list of cqlengine.Model classes within
        installed App.
        """

        apps = get_installed_apps()
        for app in apps:
            self._cql_models[app.__name__] = get_cql_models(app)
    def setUpClass(cls):

        cls.all_models = []
        apps = models.get_apps()
        for app in apps:
            cls.all_models.extend(get_cql_models(app))

        cls.all_django_tables = \
            [model.column_family_name(include_keyspace=False)
             for model in cls.all_models]
    def setUpClass(cls):
        cls.connection = get_cassandra_connection()
        cls.all_models = []
        apps = get_installed_apps()
        for app in apps:
            cls.all_models.extend(get_cql_models(app))

        cls.all_django_tables = \
            [model.column_family_name(include_keyspace=False)
             for model in cls.all_models]
    def _discover_models(self):
        """
        Return a dict containing a list of cassandra.cqlengine.Model classes
        within installed App.
        """

        apps = get_installed_apps()
        keyspace = self.connection.connection.keyspace
        for app in apps:
            self._cql_models[app.__name__] = get_cql_models(app,
                                                            keyspace=keyspace)
    def _discover_models(self):
        """
        Return a dict containing a list of cassandra.cqlengine.Model classes
        within installed App.
        """

        apps = get_installed_apps()
        keyspace = self.connection.connection.keyspace
        for app in apps:
            self._cql_models[app.__name__] = get_cql_models(app,
                                                            keyspace=keyspace)
Exemplo n.º 7
0
    def django_table_names(self, only_existing=False):
        """
        Returns a list of all table names that have associated cqlengine models
        and are present in settings.INSTALLED_APPS.
        """

        apps = models.get_apps()
        cqlengine_models = []

        for app in apps:
            cqlengine_models.extend(get_cql_models(app))

        tables = [model.column_family_name(include_keyspace=False)
                  for model in cqlengine_models]

        return tables
Exemplo n.º 8
0
    def handle_noargs(self, **options):
        # Import the 'management' module within each installed app, to register
        # dispatcher events.
        for app_name in settings.INSTALLED_APPS:
            try:
                import_module('.management', app_name)
            except ImportError as exc:
                # This is slightly hackish. We want to ignore ImportErrors
                # if the "management" module itself is missing -- but we don't
                # want to ignore the exception if the management module exists
                # but raises an ImportError for some reason. The only way we
                # can do this is to check the text of the exception. Note that
                # we're a bit broad in how we check the text, because different
                # Python implementations may not use the same text.
                # CPython uses the text "No module named management"
                # PyPy uses "No module named myproject.myapp.management"
                msg = exc.args[0]
                if not msg.startswith('No module named') \
                        or 'management' not in msg:
                    raise

        db = options.get('database')
        connection = connections[db]
        connection.connect()
        options = connection.settings_dict.get('OPTIONS', {})
        replication_opts = options.get('replication', {})
        keyspace = connection.settings_dict['NAME']

        self.stdout.write('Creating keyspace %s..' % keyspace)
        create_keyspace(keyspace, **replication_opts)

        apps = models.get_apps()
        for app in apps:
            app_models = get_cql_models(app)
            for model in app_models:
                self.stdout.write('Syncing %s.%s' %
                                  (app.__name__, model.__name__))
                sync_table(model, create_missing_keyspace=False)