1
from twisted.internet import defer
2
from twisted.python.util import mergeFunctionMetadata
4
from xmantissa.offering import InstalledOffering
6
# XXX: private import, replace with better API ASAP
7
# We probably need to wait for Twisted ticket #886 to be closed.
8
from twisted.web.client import _makeGetterFactory, HTTPClientFactory, getPage
11
def getAppStore(siteStore):
13
Retrieve the Entropy app store.
15
offering = siteStore.findUnique(InstalledOffering, InstalledOffering.offeringName == u'Entropy')
16
appStore = offering.application.open()
21
def _wrapper(*a, **kw):
22
return defer.execute(f, *a, **kw)
23
return mergeFunctionMetadata(f, _wrapper)
25
def getPageWithHeaders(uri):
29
This function is only necessary because L{twisted.web.client.getPage} is a
30
really awful API that doesn't give us access to vital response entity
31
headers such as Content-Type.
33
factory = _makeGetterFactory(str(uri), HTTPClientFactory)
34
return factory.deferred.addCallback(lambda data: (data, factory.response_headers))