Beispiel #1
0
    def __init__(self, mapper):
        """Create a router for the given routes.Mapper.

        Each route in `mapper` must specify a 'controller', which is a
        WSGI app to call.  You'll probably want to specify an 'action' as
        well and have your controller be an object that can route
        the request to the action-specific method.

        Examples:
          mapper = routes.Mapper()
          sc = ServerController()

          # Explicit mapping of one route to a controller+action
          mapper.connect(None, '/svrlist', controller=sc, action='list')

          # Actions are all implicitly defined
          mapper.resource('server', 'servers', controller=sc)

          # Pointing to an arbitrary WSGI app.  You can specify the
          # {path_info:.*} parameter so the target app can be handed just that
          # section of the URL.
          mapper.connect(None, '/v1.0/{path_info:.*}', controller=BlogApp())

        """
        # if we're only running in debug, bump routes' internal logging up a
        # notch, as it's very spammy
        if CONF.debug:
            logging.getLogger('routes.middleware').setLevel(logging.INFO)

        self.map = mapper
        self._router = routes.middleware.RoutesMiddleware(self._dispatch,
                                                          self.map)
Beispiel #2
0
 def _run(self, application, socket):
     """Start a WSGI server in a new green thread."""
     log = logging.getLogger('eventlet.wsgi.server')
     try:
         eventlet.wsgi.server(socket, application, custom_pool=self.pool,
                              log=WritableLogger(log))
     except Exception:
         LOG.exception(_('Server error'))
         raise
Beispiel #3
0
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import webob
import webob.dec

from mytest.common import logging
from mytest.common import wsgi
from mytest import config
from mytest.openstack.common import timeutils


CONF = config.CONF
LOG = logging.getLogger('access')
APACHE_TIME_FORMAT = '%d/%b/%Y:%H:%M:%S'
APACHE_LOG_FORMAT = (
    '%(remote_addr)s - %(remote_user)s [%(datetime)s] "%(method)s %(url)s '
    '%(http_version)s" %(status)s %(content_length)s')


class AccessLogMiddleware(wsgi.Middleware):
    """Writes an access log to INFO."""

    @webob.dec.wsgify
    def __call__(self, request):
        data = {
            'remote_addr': request.remote_addr,
            'remote_user': request.remote_user or '-',
            'method': request.method,
Beispiel #4
0
# vim: tabstop=4 shiftwidth=4 softtabstop=4


import json

from mytest.common import controller
from mytest.common import cms
from mytest.common import logging
from mytest import config
from mytest import exception
from mytest.openstack.common import importutils


LOG = logging.getLogger(__name__)

CONF = config.CONF

# registry of authentication methods
AUTH_METHODS = {}

class HiTony(controller.V1Controller):
    def __init__(self, *args, **kw):
        super(HiTony, self).__init__(*args, **kw)               

    def tony(self, context):
        print("context:", context)
        return {'signed': "hi, I am Tony."}
Beispiel #5
0
from mytest.common import utils
from mytest.common import wsgi
from mytest import config
from mytest import exception
from mytest import identity
from mytest.openstack.common import timeutils
from mytest import policy
from mytest import token
from mytest import trust


do_monkeypatch = not os.getenv('STANDARD_THREADS')
eventlet.patcher.monkey_patch(all=False, socket=True, time=True,
                              thread=do_monkeypatch)

LOG = logging.getLogger(__name__)
ROOTDIR = os.path.dirname(os.path.abspath(os.curdir))
VENDOR = os.path.join(ROOTDIR, 'vendor')
TESTSDIR = os.path.join(ROOTDIR, 'tests')
ETCDIR = os.path.join(ROOTDIR, 'etc')
CONF = config.CONF
DRIVERS = {}


cd = os.chdir


logging.getLogger('routes.middleware').level = logging.WARN


def rootdir(*p):