Example #1
0
    def quick_connect(self,
                      user,
                      passwd,
                      dbname=None,
                      host="localhost",
                      port=3306):
        """
        Provides a simple way to connect database instead of dealing with Configuration objects.
        """
        configuration = BaseLurkerConfig
        self.db_arguments = functions.configuration_class_to_dict(
            configuration)
        self.db_arguments.update({
            'host': host,
            'user': user,
            'passwd': passwd,
            'port': port,
        })

        if dbname:
            self.db_arguments.update({'db': dbname})

        self.configuration = configuration
        self.connect()

        return self
Example #2
0
    def __init__(self, configuration=None):

        self.db_connection = None

        if configuration:
            # Configuration class must be extended from BaseLurkerConfig
            if not issubclass(configuration, BaseLurkerConfig):
                # always wanted to name exceptions like that
                # deal with it
                raise LurkerInvalidConfigurationObjectException('First parameter of the Connection object must be a '\
                                                                ' subclass of BaseLurkerConfig class.')
            self.configuration = configuration
            if self.configuration.cache and self.configuration.cache_information:
                related_backend = self.configuration.cache_information.get("backend")
                self.cache = related_backend(*self.configuration.cache_information.get("args"), **self.configuration.cache_information.get("kwargs"))
            self.db_arguments = functions.configuration_class_to_dict(configuration)

            self.connect()
Example #3
0
    def quick_connect(self, user, passwd, dbname=None, host="localhost", port=3306):
        """
        Provides a simple way to connect database instead of dealing with Configuration objects.
        """
        configuration = BaseLurkerConfig
        self.db_arguments = functions.configuration_class_to_dict(configuration)
        self.db_arguments.update({
            'host': host,
            'user': user,
            'passwd': passwd,
            'port': port,
        })

        if dbname:
            self.db_arguments.update({'db': dbname})

        self.configuration = configuration
        self.connect()

        return self
Example #4
0
    def __init__(self, configuration=None):

        self.db_connection = None

        if configuration:
            # Configuration class must be extended from BaseLurkerConfig
            if not issubclass(configuration, BaseLurkerConfig):
                # always wanted to name exceptions like that
                # deal with it
                raise LurkerInvalidConfigurationObjectException('First parameter of the Connection object must be a '\
                                                                ' subclass of BaseLurkerConfig class.')
            self.configuration = configuration
            if self.configuration.cache and self.configuration.cache_information:
                related_backend = self.configuration.cache_information.get(
                    "backend")
                self.cache = related_backend(
                    *self.configuration.cache_information.get("args"),
                    **self.configuration.cache_information.get("kwargs"))
            self.db_arguments = functions.configuration_class_to_dict(
                configuration)

            self.connect()