# Path: solo/web/ctx.py
# LOGGER = logging.getLogger('solo.web')
# class GreenletServing(object):
# class _ThreadLocalProxy(object):
#     def __init__(self):
#     def load(self, request, response):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def clear(self):
#     def __init__(self, attrname):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __delattr__(self, name):
#     def _get_dict(self):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def __contains__(self, key):
#     def __len__(self):
#     def __nonzero__(self):
# 
# Path: solo/web/hook.py
# class HookMap(dict):
# 
#     """A map of call points to lists of callbacks (Hook objects)."""
# 
#     def __new__(cls, points=None):
#         d = dict.__new__(cls)
#         for p in points or []:
#             d[p] = []
#         return d
# 
#     def __init__(self, *a, **kw):
#         pass
# 
#     def attach(self, point, callback, failsafe=None, priority=None, **kwargs):
#         """Append a new Hook made from the supplied arguments."""
#         if point not in self:
#             self[point] = []
#         self[point].append(Hook(callback, failsafe, priority, **kwargs))
#         self[point].sort()
# 
#     def run(self, point):
#         """Execute all registered Hooks (callbacks) for the given point."""
#         exc = None
#         hooks = self.get(point, [])
#         for hook in hooks:
#             # Some hooks are guaranteed to run even if others at
#             # the same hookpoint fail. We will still log the failure,
#             # but proceed on to the next hook. The only way
#             # to stop all processing from one of these hooks is
#             # to raise SystemExit and stop the whole server.
#             if exc is None or hook.failsafe:
#                 try:
#                     hook()
#                 except (KeyboardInterrupt, SystemExit):
#                     raise
#                 except (exc.HTTPRedirection, exc.HTTPException):
#                     exc = exc_info()[1]
#                 except:
#                     exc = exc_info()[1]
#                     LOGGER.exception("Hook Error: %s", exc)
#         if exc:
#             raise exc
# 
#     def __copy__(self):
#         newmap = self.__class__()
#         # We can't just use 'update' because we want copies of the
#         # mutable values (each is a list) as well.
#         for k, v in self.items():
#             newmap[k] = v[:]
#         return newmap
#     copy = __copy__
# 
#     def __repr__(self):
#         cls = self.__class__
#         return "%s.%s(points=%r)" % (
#             cls.__module__,
#             cls.__name__,
#             self.keys()
#         )
# 
# Path: solo/web/dispatcher.py
# class RoutesDispatcher(object):
# 
#     """A Routes based dispatcher for CherryPy."""
# 
#     def __init__(self, **mapper_options):
#         """Routes dispatcher"""
#         self.controllers = {}
#         self.mapper = routes.Mapper(**mapper_options)
#         self.mapper.controller_scan = self.controllers.keys
# 
# 
#     def connect(self, name, route, controller, **kwargs):
#         self.controllers[name] = controller
#         self.mapper.connect(name, route, controller=name, **kwargs)
# 
# 
#     def match(self, request, path_info):
#         """Find the right page handler."""
# 
#         result = self.mapper.match(path_info, {'REQUEST_METHOD' : request.method})
# 
#         if not result:
#             # action, handler
#             return None, None
# 
#         request.route = result
#         params = result.copy()
#         params.pop('controller', None)
#         params.pop('action', None)
#       
#         handler = None
#         controller = result.get('controller')
#         controller = self.controllers.get(controller, controller)
#         if controller:
#             if isinstance(controller, classtype):
#                 controller = controller()
# 
#         action = result.get('action')
#         if action is not None:
#             handler = getattr(controller, action, None)
#         else:
#             handler = controller
# 
#         if request.method == 'GET':
#             reqparams = request.GET.mixed()
#         elif request.method != 'HEAD':
#             reqparams = request.POST.mixed()
#         else:
#             reqparams = {}
# 
#         reqparams.update(params)
#         handler = PageHandler(handler, **reqparams)
# 
#         return action, handler


from webob import exc
from webob import Request, Response
from sys import exc_info
from solo.web.ctx import serving
from solo.web.hook import HookMap
from solo.web.dispatcher import RoutesDispatcher
        from solo.web.asset import AssetController
import logging
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.







LOGGER = logging.getLogger('solo.web')



class App(object):


    hookpoints = ['on_start_resource', 'before_handler',
                'on_end_resource', 'on_end_request',
                'before_error_response', 'after_error_response']


    def __init__(self, name='Lilac', encoding='utf8', debug=False, dispatcher=None):

# Path: solo/web/ctx.py
# LOGGER = logging.getLogger('solo.web')
# class GreenletServing(object):
# class _ThreadLocalProxy(object):
#     def __init__(self):
#     def load(self, request, response):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def clear(self):
#     def __init__(self, attrname):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __delattr__(self, name):
#     def _get_dict(self):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def __contains__(self, key):
#     def __len__(self):
#     def __nonzero__(self):
# 
# Path: solo/web/hook.py
# class HookMap(dict):
# 
#     """A map of call points to lists of callbacks (Hook objects)."""
# 
#     def __new__(cls, points=None):
#         d = dict.__new__(cls)
#         for p in points or []:
#             d[p] = []
#         return d
# 
#     def __init__(self, *a, **kw):
#         pass
# 
#     def attach(self, point, callback, failsafe=None, priority=None, **kwargs):
#         """Append a new Hook made from the supplied arguments."""
#         if point not in self:
#             self[point] = []
#         self[point].append(Hook(callback, failsafe, priority, **kwargs))
#         self[point].sort()
# 
#     def run(self, point):
#         """Execute all registered Hooks (callbacks) for the given point."""
#         exc = None
#         hooks = self.get(point, [])
#         for hook in hooks:
#             # Some hooks are guaranteed to run even if others at
#             # the same hookpoint fail. We will still log the failure,
#             # but proceed on to the next hook. The only way
#             # to stop all processing from one of these hooks is
#             # to raise SystemExit and stop the whole server.
#             if exc is None or hook.failsafe:
#                 try:
#                     hook()
#                 except (KeyboardInterrupt, SystemExit):
#                     raise
#                 except (exc.HTTPRedirection, exc.HTTPException):
#                     exc = exc_info()[1]
#                 except:
#                     exc = exc_info()[1]
#                     LOGGER.exception("Hook Error: %s", exc)
#         if exc:
#             raise exc
# 
#     def __copy__(self):
#         newmap = self.__class__()
#         # We can't just use 'update' because we want copies of the
#         # mutable values (each is a list) as well.
#         for k, v in self.items():
#             newmap[k] = v[:]
#         return newmap
#     copy = __copy__
# 
#     def __repr__(self):
#         cls = self.__class__
#         return "%s.%s(points=%r)" % (
#             cls.__module__,
#             cls.__name__,
#             self.keys()
#         )
# 
# Path: solo/web/dispatcher.py
# class RoutesDispatcher(object):
# 
#     """A Routes based dispatcher for CherryPy."""
# 
#     def __init__(self, **mapper_options):
#         """Routes dispatcher"""
#         self.controllers = {}
#         self.mapper = routes.Mapper(**mapper_options)
#         self.mapper.controller_scan = self.controllers.keys
# 
# 
#     def connect(self, name, route, controller, **kwargs):
#         self.controllers[name] = controller
#         self.mapper.connect(name, route, controller=name, **kwargs)
# 
# 
#     def match(self, request, path_info):
#         """Find the right page handler."""
# 
#         result = self.mapper.match(path_info, {'REQUEST_METHOD' : request.method})
# 
#         if not result:
#             # action, handler
#             return None, None
# 
#         request.route = result
#         params = result.copy()
#         params.pop('controller', None)
#         params.pop('action', None)
#       
#         handler = None
#         controller = result.get('controller')
#         controller = self.controllers.get(controller, controller)
#         if controller:
#             if isinstance(controller, classtype):
#                 controller = controller()
# 
#         action = result.get('action')
#         if action is not None:
#             handler = getattr(controller, action, None)
#         else:
#             handler = controller
# 
#         if request.method == 'GET':
#             reqparams = request.GET.mixed()
#         elif request.method != 'HEAD':
#             reqparams = request.POST.mixed()
#         else:
#             reqparams = {}
# 
#         reqparams.update(params)
#         handler = PageHandler(handler, **reqparams)
# 
#         return action, handler


# Path: solo/web/app.py
from webob import exc
from webob import Request, Response
from sys import exc_info
from solo.web.ctx import serving
from solo.web.hook import HookMap
from solo.web.dispatcher import RoutesDispatcher
        from solo.web.asset import AssetController
import logging

# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.







LOGGER = logging.getLogger('solo.web')



class App(object):


    hookpoints = ['on_start_resource', 'before_handler',
                'on_end_resource', 'on_end_request',
                'before_error_response', 'after_error_response']


    def __init__(self, name='Lilac', encoding='utf8', debug=False, dispatcher=None):

        self.dispatcher = dispatcher or RoutesDispatcher()