# Path: snakeguice/modules.py
# class Module(object):
#     """Base class for all standard modules."""
# 
#     def __init__(self):
#         self._injector = None
# 
#     def install(self, binder, module):
#         """Add another module's bindings to a binder."""
#         ModuleAdapter(module, self._injector).configure(binder)
# 
#     def run_configure(self, binder):
#         """A hook for intercepting the configure method. Allows different
#         module implementations to change the binder passed to configure.
#         """
#         self.configure(binder)
# 
#     def configure(self, binder):
#         """A subclass should override this to configure a binder."""
#         raise NotImplementedError
# 
#     def set_injector(self, injector):
#         self._injector = injector


import inspect
import routes
from webob import Request, Response
from webob.exc import HTTPNotFound
from snakeguice.modules import Module
        self.mapper = mapper
        self._annotation = annotation
        self.controller_map = {}

    def connect(self, *args, **kwargs):
        controller = kwargs.get('controller')

        if controller is None:
            raise TypeError('no controller specified')

        key = unicode((id(controller), repr(controller)))
        self.controller_map[key] = controller
        kwargs['controller'] = key
        self.mapper.connect(*args, **kwargs)

    def match(self, url, environ):
        # TODO: i have a patch that makes this suck less - i need to submit it
        old_environ, self.mapper.environ = self.mapper.environ, environ
        try:
            return self.mapper.match(url)
        finally:
            self.mapper.environ = old_environ


class RoutesModule(Module):

    annotation = None

    def run_configure(self, binder):
        self._mapper = routes.Mapper()

# Path: snakeguice/modules.py
# class Module(object):
#     """Base class for all standard modules."""
# 
#     def __init__(self):
#         self._injector = None
# 
#     def install(self, binder, module):
#         """Add another module's bindings to a binder."""
#         ModuleAdapter(module, self._injector).configure(binder)
# 
#     def run_configure(self, binder):
#         """A hook for intercepting the configure method. Allows different
#         module implementations to change the binder passed to configure.
#         """
#         self.configure(binder)
# 
#     def configure(self, binder):
#         """A subclass should override this to configure a binder."""
#         raise NotImplementedError
# 
#     def set_injector(self, injector):
#         self._injector = injector


# Path: snakeguice/extras/snakeweb.py
import inspect
import routes
from webob import Request, Response
from webob.exc import HTTPNotFound
from snakeguice.modules import Module

        self.mapper = mapper
        self._annotation = annotation
        self.controller_map = {}

    def connect(self, *args, **kwargs):
        controller = kwargs.get('controller')

        if controller is None:
            raise TypeError('no controller specified')

        key = unicode((id(controller), repr(controller)))
        self.controller_map[key] = controller
        kwargs['controller'] = key
        self.mapper.connect(*args, **kwargs)

    def match(self, url, environ):
        # TODO: i have a patch that makes this suck less - i need to submit it
        old_environ, self.mapper.environ = self.mapper.environ, environ
        try:
            return self.mapper.match(url)
        finally:
            self.mapper.environ = old_environ


class RoutesModule(Module):

    annotation = None

    def run_configure(self, binder):
        self._mapper = routes.Mapper()

        self.routes_binder = RoutesBinder(self._mapper, self.annotation)