Package Products :: Package ZenUtils :: Package extdirect :: Package zope :: Module router |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenUtils.extdirect.zope.router

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2009, Zenoss Inc.
     5  #
     6  # This program is free software; you can redistribute it and/or modify it
     7  # under the terms of the GNU General Public License version 2 as published by
     8  # the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13  from Products.ZenUtils.extdirect.router import DirectRouter
    14
    15 -class ZopeDirectRouter(DirectRouter):
    16 -    def __init__(self, context, request=None):
    17          self.context = context
    18          self.request = request
    19
    20 -    def __call__(self):
    21          try:
    22              # Zope 3
    23              body = self.request.bodyStream.getCacheStream().getvalue()
    24          except AttributeError:
    25              # Zope 2
    26              body = self.request.get('BODY')
    27          self.request.response.setHeader('Content-Type', 'application/json')
    28          return super(ZopeDirectRouter, self).__call__(body)
    29