Trees | Indices | Help |
---|
|
1 # -*- Mode: Python; test-case-name: flumotion.test.test_component_providers -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007,2008 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 21 22 import os 23 24 from twisted.web import static 25 26 from flumotion.component.misc.httpserver import fileprovider 27 from flumotion.component.misc.httpserver.fileprovider import InsecureError 28 from flumotion.component.misc.httpserver.fileprovider import NotFoundError 29 3032 # Add our own mime types to the ones parsed from /etc/mime.types 33 d = static.loadMimeTypes() 34 d['.flv'] = 'video/x-flv' 35 d['.mp4'] = 'video/mp4' 36 return d37 3840 41 contentTypes = loadMimeTypes() 42 43 # Override parent class property by an attribute 44 mimeType = None 458247 self.path = path 48 ext = os.path.splitext(path)[1] 49 self.mimeType = self.contentTypes.get(ext.lower(), None)50 53 57 60 61 62 ## Protected Methods ## 6365 """ 66 @param name: the name of a child of the pointed directory 67 @type name: str 68 69 @return: the path of the child 70 @rtype: str 71 @raises InsecureError: if the specified name compromise security 72 """ 73 norm = os.path.normpath(name) 74 if os.sep in norm: 75 raise InsecureError("Child name '%s' contains one or more " 76 "directory separators" % (name, )) 77 childpath = os.path.abspath(os.path.join(self.path, norm)) 78 if not childpath.startswith(self.path): 79 raise InsecureError("Path '%s' is not a child of '%s'" 80 % (childpath, self.path)) 81 return childpath
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Nov 15 09:18:25 2009 | http://epydoc.sourceforge.net |