<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _dbdir():
 """Returns the path to the directory where acorn DBs are stored. """

    global dbdir
    from os import mkdir, path, getcwd, chdir
    
    if dbdir is None:
        from acorn.config import settings
        config = settings("acorn")
        if (config.has_section("database") and
            config.has_option("database", "folder")):
            dbdir = config.get("database", "folder")
        else: # pragma: no cover
            raise ValueError("The folder to save DBs in must be configured"
                             "  in 'acorn.cfg'")

    #It is possible to specify the database path relative to the repository
    #root. path.abspath will map it correctly if we are in the root directory.
    from acorn.utility import abspath
    if not path.isabs(dbdir):
        #We want absolute paths to make it easier to port this to other OS.
        dbdir = abspath(dbdir)
        
    if not path.isdir(dbdir): # pragma: no cover
        mkdir(dbdir)
        
    return dbdir