# Path: cavedb/middleware.py
# def get_request_uri():
#     return getattr(THREAD_LOCALS, 'request_uri', None)
# 
# def get_valid_bulletins():
#     return getattr(THREAD_LOCALS, 'valid_bulletins', [])


import os
import re
import time
import cavedb.docgen_all
import cavedb.perms
import cavedb.utils
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
from cavedb.middleware import get_request_uri, get_valid_bulletins
                    continue

                ret += '<a href="%s/region/%s/map/%s">%s %s</a><br/>\n' % \
                               (baseurl, region.id, gismap.name, gismap.name, region.region_name)

            ret += '<br/>\n'

        return ret


    show_maps.short_description = "GIS Maps"
    show_maps.allow_tags = True


    class Meta:
        ordering = ('bulletin_name',)


# Restrict the list of choices to items that are underneath the current bulletin
class BulletinChoice(models.ForeignKey):
    #pylint: disable=abstract-method

    def formfield(self, **kwargs):
        #pylint: disable=protected-access

        # The bulletin_id appears to be only available on the form. Since that
        # information is not available here, retrieve the bulletin_id from the
        # URL.

        regex = re.compile(r'.*?bulletin\\/(\d+)\\/')

# Path: cavedb/middleware.py
# def get_request_uri():
#     return getattr(THREAD_LOCALS, 'request_uri', None)
# 
# def get_valid_bulletins():
#     return getattr(THREAD_LOCALS, 'valid_bulletins', [])


# Path: cavedb/models.py
import os
import re
import time
import cavedb.docgen_all
import cavedb.perms
import cavedb.utils
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
from cavedb.middleware import get_request_uri, get_valid_bulletins

                    continue

                ret += '<a href="%s/region/%s/map/%s">%s %s</a><br/>\n' % \
                               (baseurl, region.id, gismap.name, gismap.name, region.region_name)

            ret += '<br/>\n'

        return ret


    show_maps.short_description = "GIS Maps"
    show_maps.allow_tags = True


    class Meta:
        ordering = ('bulletin_name',)


# Restrict the list of choices to items that are underneath the current bulletin
class BulletinChoice(models.ForeignKey):
    #pylint: disable=abstract-method

    def formfield(self, **kwargs):
        #pylint: disable=protected-access

        # The bulletin_id appears to be only available on the form. Since that
        # information is not available here, retrieve the bulletin_id from the
        # URL.

        regex = re.compile(r'.*?bulletin\\/(\d+)\\/')

        matches = regex.match(get_request_uri())