'Ensure that the given lang matches case exactly with the lang
in the db. If this invariant is broken, then weird things with
caching can result.'

def _check_lang(self, lang):

    if exists(self.base_dir):
        lang_path = join(self.base_dir, 'lang')
        try:
            fin = open(lang_path, 'r')
        except EnvironmentError as ex:
            self.db.corruption('LangZone._check_lang', ("could    not    open    `%s':    %s" % (lang_path, ex)), 'recover')
            fin = open(lang_path, 'w')
            try:
                fin.write(lang)
            finally:
                fin.close()
        else:
            try:
                lang_on_disk = fin.read().strip()
            finally:
                fin.close()
            assert (lang_on_disk == lang)
