當前位置: 首頁>>代碼示例>>Python>>正文


Python JsonDict.dumps方法代碼示例

本文整理匯總了Python中meresco.components.json.JsonDict.dumps方法的典型用法代碼示例。如果您正苦於以下問題:Python JsonDict.dumps方法的具體用法?Python JsonDict.dumps怎麽用?Python JsonDict.dumps使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在meresco.components.json.JsonDict的用法示例。


在下文中一共展示了JsonDict.dumps方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dna

# 需要導入模塊: from meresco.components.json import JsonDict [as 別名]
# 或者: from meresco.components.json.JsonDict import dumps [as 別名]
def dna(reactor, port, dataPath, logPath, statePath, harvesterStatusUrl, **ignored):
    harvesterData = HarvesterData(dataPath)
    repositoryStatus = be((RepositoryStatus(logPath, statePath),
            (harvesterData,)
        ))
    configDict = JsonDict(
            logPath=logPath,
            statePath=statePath,
            harvesterStatusUrl=harvesterStatusUrl,
            dataPath=dataPath,
        )

    return \
        (Observable(),
            (ObservableHttpServer(reactor, port),
                (ApacheLogger(stdout),
                    (PathFilter("/info/version"),
                        (StringServer(VERSION_STRING, ContentTypePlainText), )
                    ),
                    (PathFilter("/info/config"),
                        (StringServer(configDict.dumps(), ContentTypeJson), )
                    ),
                    (PathFilter("/static"),
                        (PathRename(lambda name: name[len('/static/'):]),
                            (FileServer(seecrWebLibPath),)
                        )
                    ),
                    (PathFilter('/', excluding=['/info/version', '/info/config', '/static', '/action', '/get']),
                        (DynamicHtml(
                                [dynamicHtmlPath],
                                reactor=reactor,
                                additionalGlobals = {
                                    'time': time,
                                    'harvesterStatusUrl': harvesterStatusUrl,
                                    'escapeXml': escapeXml,
                                    'compose': compose,
                                },
                                indexPage="/index.html",
                            ),
                            (harvesterData,),
                            (repositoryStatus,),
                        )
                    ),
                    (PathFilter('/action'),
                        (HarvesterDataActions(),
                            (harvesterData,)
                        ),
                    ),
                    (PathFilter('/get'),
                        (HarvesterDataRetrieve(),
                            (harvesterData,),
                            (repositoryStatus,),
                        )
                    )
                )
            )
        )
開發者ID:,項目名稱:,代碼行數:59,代碼來源:

示例2: dna

# 需要導入模塊: from meresco.components.json import JsonDict [as 別名]
# 或者: from meresco.components.json.JsonDict import dumps [as 別名]
def dna(reactor, port, dataPath, logPath, statePath, externalUrl, **ignored):
    passwordFilename = join(dataPath, 'users.txt')
    harvesterData = HarvesterData(dataPath)
    repositoryStatus = be(
        (RepositoryStatus(logPath, statePath),
            (harvesterData, )
        )
    )
    configDict = JsonDict(
        logPath=logPath,
        statePath=statePath,
        externaUrl=externalUrl,
        dataPath=dataPath,
    )

    passwordFile = PasswordFile(filename=passwordFilename)
    basicHtmlLoginHelix = (BasicHtmlLoginForm(
        action="/login.action",
        loginPath="/login",
        home="/index",
        rememberMeCookie=False,
        lang="nl"),

        (passwordFile, )
    )

    userActions = UserActions(dataDir=dataPath)
    userActionsHelix = (userActions,
        (passwordFile, )
    )

    return \
        (Observable(),
            (ObservableHttpServer(reactor, port),
                (ApacheLogger(stdout),
                    (BasicHttpHandler(),
                        (SessionHandler(),
                            (CookieMemoryStore(name="meresco-harvester", timeout=2*60*60), ),
                            (PathFilter("/info/version"),
                                (StringServer(VERSION_STRING, ContentTypePlainText), )
                            ),
                            (PathFilter("/info/config"),
                                (StringServer(configDict.dumps(), ContentTypeJson), )
                            ),
                            (PathFilter('/login.action'),
                                basicHtmlLoginHelix
                            ),
                            (PathFilter('/user.action'),
                                userActionsHelix
                            ),
                            (PathFilter("/static"),
                                (PathRename(lambda name: name[len('/static/'):]),
                                    (FileServer([seecrWebLibPath, staticHtmlPath]),)
                                )
                            ),
                            (PathFilter('/', excluding=['/info/version', '/info/config', '/static', '/action', '/get', '/login.action', '/user.action']),
                                (SecureZone("/login", excluding="/index", defaultLanguage="nl"),
                                    (DynamicHtml(
                                            [dynamicHtmlPath],
                                            reactor=reactor,
                                            additionalGlobals={
                                                'externalUrl': externalUrl,
                                                'escapeXml': escapeXml,
                                                'compose': compose,
                                                'VERSION': VERSION,
                                                'CONFIG': configDict,
                                                'Timeslot': Timeslot,
                                                'ThroughputAnalyser': ThroughputAnalyser,
                                                'dateSince': dateSince,
                                                'callable': callable,
                                                'OnlineHarvest': OnlineHarvest,
                                                'StringIO': StringIO,
                                                'okPlainText': okPlainText,
                                                'ZuluTime': ZuluTime,
                                                'xpathFirst': xpathFirst,
                                            },
                                            indexPage="/index",
                                        ),
                                        basicHtmlLoginHelix,
                                        (harvesterData,),
                                        (repositoryStatus,),
                                        userActionsHelix,
                                    )
                                )
                            ),
                            (PathFilter('/action'),
                                (HarvesterDataActions(),
                                    (harvesterData,)
                                ),
                            ),
                            (PathFilter('/get'),
                                (HarvesterDataRetrieve(),
                                    (harvesterData,),
                                    (repositoryStatus,),
                                )
                            )
                        )
                    )
                )
            )
#.........這裏部分代碼省略.........
開發者ID:seecr,項目名稱:meresco-harvester,代碼行數:103,代碼來源:server.py


注:本文中的meresco.components.json.JsonDict.dumps方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。