Exemplo n.º 1
0
    def open(self, configuration):
        """Open the connection.

        The connection must be set up in the 'connection' instance
        attribute.  While redefining this method, you MUST call the
        parent AFTER setting up the connection.

        """
        Driver.open(self, configuration)
        self.check_existing_tables()
Exemplo n.º 2
0
    def open(self, configuration):
        """Open the connexion."""
        Driver.open(self, configuration)
        self.db_name = configuration["datas"]
        self.inc_name = configuration["increments"]

        # Try to connect
        self.connection = pymongo.Connection()

        # Create the datas and increments collections
        self.datas = self.connection[self.db_name]
        self.increments = self.connection[self.inc_name]

        # Set the collections
        self.collections = {}
        self.inc_collections = {}

        # Keep the IDs in cache
        self.line_ids = {}
        self.id_lines = {}
Exemplo n.º 3
0
    def open(self, configuration):
        """Open the connexion."""
        Driver.open(self, configuration)
        location = configuration["location"]
        location = location.replace("\\", "/")
        if location.startswith("~"):
            location = os.path.expanduser("~") + location[1:]

        if location.endswith("/"):
            location = location[:-1]

        if not os.path.exists(location):
            # Try to create it
            os.makedirs(location)

        if not os.access(location, os.R_OK):
            raise exceptions.DriverInitializationError(
                    "cannot read in {}".format(location))
        if not os.access(location, os.W_OK):
            raise exceptions.DriverInitializationError(
                    "cannot write in {}".format(location))

        self.location = location
        self.files = {}