Package osaf :: Package servlets :: Module lobviewer
[hide private]
[frames] | no frames]

Source Code for Module osaf.servlets.lobviewer

 1  #   Copyright (c) 2003-2007 Open Source Applications Foundation 
 2  # 
 3  #   Licensed under the Apache License, Version 2.0 (the "License"); 
 4  #   you may not use this file except in compliance with the License. 
 5  #   You may obtain a copy of the License at 
 6  # 
 7  #       http://www.apache.org/licenses/LICENSE-2.0 
 8  # 
 9  #   Unless required by applicable law or agreed to in writing, software 
10  #   distributed under the License is distributed on an "AS IS" BASIS, 
11  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
12  #   See the License for the specific language governing permissions and 
13  #   limitations under the License. 
14   
15   
16  import logging 
17  from osaf import webserver 
18   
19  logger = logging.getLogger(__name__) 
20   
21 -class LobViewerResource(webserver.AuthenticatedResource):
22 isLeaf = True
23 - def render_GET(self, request):
24 25 try: 26 # The Server item will give us the repositoryView during 27 # startup. 28 repoView = self.myView 29 30 (uuid, attrName) = request.postpath 31 item = repoView.findUUID(uuid) 32 attr = getattr(item, attrName) 33 mimeType = attr.mimetype 34 request.setHeader('Content-Type', mimeType) 35 input = attr.getInputStream() 36 data = input.read() 37 input.close() 38 request.setHeader('Content-Length', len(data)) 39 return data 40 41 except Exception, e: 42 logging.exception(e) 43 return ""
44