# Path: snakeguice/decorators.py
# def inject(**kwargs):
# 
#     scope = kwargs.get('scope')
#     if 'scope' in kwargs:
#         del kwargs['scope']
# 
#     def _inject(func):
#         class_locals = enclosing_frame().f_locals
# 
#         guice_data = GuiceData.from_class_dict(class_locals)
# 
#         annotations = getattr(func, '__guice_annotations__', {})
# 
#         gmethod = dict((k, GuiceArg(v, annotations.get(k)))
#                        for k, v in kwargs.items())
# 
#         _validate_func_args(func, kwargs)
#         if func.__name__ == '__init__':
#             guice_data.init = gmethod
#         else:
#             guice_data.methods[func.__name__] = gmethod
# 
#         return func
# 
#     return _inject
# 
# class annotate(object):
# 
#     def __init__(self, **kwargs):
#         self.kwargs = kwargs
# 
#     def __call__(self, method):
#         class_locals = enclosing_frame().f_locals
#         if '__guice__' in class_locals:
#             if method.__name__ in class_locals['__guice__'].methods:
#                 raise Exception('annotate must be applied before inject')
#         method.__guice_annotations__ = self.kwargs
#         return method


from os import path
from mako.template import Template
from webob import Response
from snakeguice import inject, annotate
from forms import MyForm
import formencode
    @inject(template_dir=str)
    @annotate(template_dir='base template directory')
    def __init__(self, template_dir):
        self._template_dir = template_dir

    def _load_template(self, filename):
        filename = path.join(self._template_dir, filename)
        return Template(filename=filename)


class HomeController(BaseController):

    def index(self, request):
        kwargs = dict(name='', email='', errors={})
        template = self._load_template('templates/index.mako')
        return Response(template.render(**kwargs))

    def form(self, request):
        errors = {}
        try:
            formdata = MyForm().to_python(request.POST)
        except formencode.Invalid, e:
            errors = e.unpack_errors()

        if errors:
            kwargs = dict(name=request.POST.get('name', ''),
                          email=request.POST.get('email', ''), errors=errors)
            template = self._load_template('templates/index.mako')
            return Response(template.render(**kwargs))
        else:

# Path: snakeguice/decorators.py
# def inject(**kwargs):
# 
#     scope = kwargs.get('scope')
#     if 'scope' in kwargs:
#         del kwargs['scope']
# 
#     def _inject(func):
#         class_locals = enclosing_frame().f_locals
# 
#         guice_data = GuiceData.from_class_dict(class_locals)
# 
#         annotations = getattr(func, '__guice_annotations__', {})
# 
#         gmethod = dict((k, GuiceArg(v, annotations.get(k)))
#                        for k, v in kwargs.items())
# 
#         _validate_func_args(func, kwargs)
#         if func.__name__ == '__init__':
#             guice_data.init = gmethod
#         else:
#             guice_data.methods[func.__name__] = gmethod
# 
#         return func
# 
#     return _inject
# 
# class annotate(object):
# 
#     def __init__(self, **kwargs):
#         self.kwargs = kwargs
# 
#     def __call__(self, method):
#         class_locals = enclosing_frame().f_locals
#         if '__guice__' in class_locals:
#             if method.__name__ in class_locals['__guice__'].methods:
#                 raise Exception('annotate must be applied before inject')
#         method.__guice_annotations__ = self.kwargs
#         return method


# Path: examples/wsgiapp/controllers.py
from os import path
from mako.template import Template
from webob import Response
from snakeguice import inject, annotate
from forms import MyForm
import formencode

    @inject(template_dir=str)
    @annotate(template_dir='base template directory')
    def __init__(self, template_dir):
        self._template_dir = template_dir

    def _load_template(self, filename):
        filename = path.join(self._template_dir, filename)
        return Template(filename=filename)


class HomeController(BaseController):

    def index(self, request):
        kwargs = dict(name='', email='', errors={})
        template = self._load_template('templates/index.mako')
        return Response(template.render(**kwargs))

    def form(self, request):
        errors = {}
        try:
            formdata = MyForm().to_python(request.POST)
        except formencode.Invalid, e:
            errors = e.unpack_errors()

        if errors:
            kwargs = dict(name=request.POST.get('name', ''),
                          email=request.POST.get('email', ''), errors=errors)
            template = self._load_template('templates/index.mako')
            return Response(template.render(**kwargs))
        else:

            name = request.POST.get('name', '')