c.l.b.l.MixedFileAliasView(LaunchpadView) : class documentation

Part of canonical.launchpad.browser.librarian View In Hierarchy

Known subclasses: canonical.launchpad.browser.librarian.SafeStreamOrRedirectLibraryFileAliasView

Implements interfaces: zope.publisher.interfaces.browser.IBrowserPublisher

Stream or redirects to ILibraryFileAlias.

If the file is public, it will redirect to the files http url.

Otherwise if the feature flag publicrestrictedlibrarian is set to 'on' this will allocate a token and redirect to the aliases private url.

Otherwise it will proxy the file in the appserver.

Once we no longer have any proxy code at all it should be possible to consolidate this with LibraryFileAliasView.

Note that streaming restricted files is a security concern - they show up in the launchpad.net domain rather than launchpadlibrarian.net and thus we have to take special care about their origin. SafeStreamOrRedirectLibraryFileAliasView is used when we do not trust the content, otherwise StreamOrRedirectLibraryFileAliasView. We are working to remove both of these views entirely, but some transition will be needed.

The context provides a file-like interface - it can be opened and closed and read from.

Method getFileContents Undocumented
Method __call__ Streams the contents of the context ILibraryFileAlias.
Method browserDefault Decides how to deliver the file.
Method publishTraverse See IBrowserPublisher - can't traverse below a file.
Method _when_streaming Hook for SafeStreamOrRedirectLibraryFileAliasView.
def getFileContents(self):
Undocumented
def __call__(self):
Streams the contents of the context ILibraryFileAlias.

The file content is downloaded in chunks directly to a tempfile.TemporaryFile avoiding using large amount of memory.

The temporary file is returned to the zope publishing machinery as documented in lib/zope/publisher/httpresults.txt, after adjusting the response 'Content-Type' appropriately.

This method explicit ignores the local 'http_proxy' settings.

def browserDefault(self, request):
Decides how to deliver the file.

The options are:
  • redirect to the contexts http url
  • redirect to a time limited secure url
  • stream the file content.

Only restricted file contents are streamed, finishing the traversal chain with this view. If the context file is public return the appropriate RedirectionView for its HTTP url.

def publishTraverse(self, request, name):
See IBrowserPublisher - can't traverse below a file.
def _when_streaming(self):
Hook for SafeStreamOrRedirectLibraryFileAliasView.
API Documentation for Launchpad, generated by pydoctor at 2010-09-27 00:00:11.