本文整理汇总了Python中meresco.html.DynamicHtml.addStrand方法的典型用法代码示例。如果您正苦于以下问题:Python DynamicHtml.addStrand方法的具体用法?Python DynamicHtml.addStrand怎么用?Python DynamicHtml.addStrand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meresco.html.DynamicHtml
的用法示例。
在下文中一共展示了DynamicHtml.addStrand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LuceneRemoteService
# 需要导入模块: from meresco.html import DynamicHtml [as 别名]
# 或者: from meresco.html.DynamicHtml import addStrand [as 别名]
class LuceneRemoteService(Observable):
def __init__(self, reactor, conversion=None, **kwargs):
Observable.__init__(self, **kwargs)
self._conversion = Conversion() if conversion is None else conversion
self._dynamicHtml = DynamicHtml([dynamicPath],
reactor=reactor,
notFoundPage='notFound',
additionalGlobals={
'VERSION': version,
'allCoreInfo': self._allCoreInfo,
'parseCql': parseString,
'cqlToExpression': cqlToExpression,
'cql2string': cql2string,
'dumps': dumps,
}
)
self._internalTree = be((Observable(),
(PathFilter('/', excluding=['/static', '/version']),
(self._dynamicHtml,)
),
(PathFilter('/static'),
(PathRename(lambda path: path[len('/static'):]),
(FileServer(staticPath),)
)
),
(PathFilter('/version'),
(StringServer("Meresco Lucene version %s" % version, ContentTypePlainText),)
),
))
def addObserver(self, *args, **kwargs):
Observable.addObserver(self, *args, **kwargs)
self._dynamicHtml.addObserver(*args, **kwargs)
def addStrand(self, *args, **kwargs):
Observable.addStrand(self, *args, **kwargs)
self._dynamicHtml.addStrand(*args, **kwargs)
def handleRequest(self, path, Method, Body=None, **kwargs):
if Method == 'POST' and path.endswith('/__lucene_remote__'):
yield self._handleQuery(Body)
elif '/info' in path:
originalPath = path
_, _, path = path.partition('/info')
yield self._internalTree.all.handleRequest(path=path or '/', originalPath=originalPath, Method=Method, Body=Body, **kwargs)
def _handleQuery(self, Body):
try:
message, kwargs = self._conversion.jsonLoadMessage(Body)
if message not in _ALLOWED_METHODS:
raise ValueError('Expected %s' % (' or '.join('"%s"' % m for m in _ALLOWED_METHODS)))
response = yield self.any.unknown(message=message, **kwargs)
except Exception, e:
print_exc()
x = format_exc() # returns 'None' if e is a Java Error
yield serverErrorPlainText
yield x if x and x.strip() != 'None' else repr(e)
return
yield Ok
yield ContentTypeHeader + 'application/json' + CRLF
yield CRLF
yield response.asJson()