Exemplo n.º 1
0
def getSite(db, resources=['add', 'api', 'republish', 'static'], repub=None):
    """Get the twisted site for smap-archiver"""
    root = RootResource(value={'Contents': resources})
    if not repub:
        repub = republisher.ReResource(db)
    if 'republish' in resources:
        root.putChild('republish', repub)
    if 'add' in resources:
        root.putChild('add', DataResource(db, repub))
    if 'api' in resources:
        root.putChild('api', api.Api(db))
    if 'static' in resources:
        print "static"
        root.putChild('static', static.File('static'))
    return server.Site(root)
Exemplo n.º 2
0
def getSite(db, 
            resources=['add', 'api', 'republish', 'static'],
            repub=None):
    """Get the twisted site for smap-archiver"""
    root = RootResource(value={'Contents': resources})
    if not repub:
        repub = republisher.ReResource(db)
    if 'republish' in resources:
        root.putChild('republish', repub)
    if 'add' in resources:
        root.putChild('add', DataResource(db, repub))
    if 'api' in resources:
        root.putChild('api', api.Api(db))
    if 'static' in resources:
        print "static"
        root.putChild('static', static.File('static'))
    return server.Site(root)
Exemplo n.º 3
0
def getSite(db,
            resources=['add', 'api', 'republish', 'wsrepublish', 'static'],
            http_repub=None,
            websocket_repub=None,
            mongo_repub=None,
            pg_repub=None):
    """Get the twisted site for smap-archiver"""
    root = RootResource(value={'Contents': resources})
    if not http_repub:
        http_repub = republisher.ReResource(db)
    if not websocket_repub:
        websocket_repub = republisher.WebSocketRepublishResource(db)

    def repub_fn(*args):
        dl = []
        if 'republish' in resources:
            http_repub.republish(*copy.deepcopy(args))
        if 'wsrepublish' in resources:
            websocket_repub.republish(*copy.deepcopy(args))
        if mongo_repub:
            dl.append(mongo_repub.republish(*copy.deepcopy(args)))
        if pg_repub:
            dl.append(pg_repub.republish(*copy.deepcopy(args)))
        return defer.DeferredList(dl, fireOnOneErrback=True)

    if 'republish' in resources:
        root.putChild('republish', http_repub)
    if 'wsrepublish' in resources:
        root.putChild('wsrepublish', websocket_repub)
    if 'add' in resources:
        root.putChild('add', DataResource(db, repub_fn))
    if 'api' in resources:
        root.putChild('api', api.Api(db))
    if 'static' in resources:
        root.putChild('static', static.File('static'))
    return server.Site(root)
Exemplo n.º 4
0
def getSite(db,
            resources=['add', 'api', 'republish', 'wsrepublish', 'static'],
            http_repub=None,
            websocket_repub=None):
    """Get the twisted site for smap-archiver"""
    root = RootResource(value={'Contents': resources})
    if not http_repub:
        http_repub = republisher.ReResource(db)
    if not websocket_repub:
        websocket_repub = republisher.WebSocketRepublishResource(db)

    def repub_fn(*args):
        if 'republish' in resources:
            http_repub.republish(*args)
        if 'wsrepublish' in resources:
            websocket_repub.republish(*args)

    if 'republish' in resources:
        root.putChild('republish', http_repub)
    if 'wsrepublish' in resources:
        root.putChild('wsrepublish', websocket_repub)
    if 'add' in resources:
        root.putChild('add', DataResource(db, repub_fn))
    if 'api' in resources:
        root.putChild('api', api.Api(db))
    if 'static' in resources:
        print "static"
        root.putChild('static', static.File('static'))
    return server.Site(root)
Exemplo n.º 5
0
Arquivo: server.py Projeto: ahaas/smap
def getSite(db, 
            resources=['add', 'api', 'republish', 'wsrepublish', 'static'],
            http_repub=None, websocket_repub=None):
    """Get the twisted site for smap-archiver"""
    root = RootResource(value={'Contents': resources})
    if not http_repub:
        http_repub = republisher.ReResource(db)
    if not websocket_repub:
        websocket_repub = republisher.WebSocketRepublishResource(db)

    def repub_fn(*args):        
        if 'republish' in resources:
            http_repub.republish(*args)
        if 'wsrepublish' in resources:
            websocket_repub.republish(*args)

    if 'republish' in resources:
        root.putChild('republish', http_repub)
    if 'wsrepublish' in resources:
        root.putChild('wsrepublish', websocket_repub)
    if 'add' in resources:
        root.putChild('add', DataResource(db, repub_fn))
    if 'api' in resources:
        root.putChild('api', api.Api(db))
    if 'static' in resources:
        print "static"
        root.putChild('static', static.File('static'))
    return server.Site(root)
Exemplo n.º 6
0
def getSite(db, 
            resources=['add', 'api', 'republish', 'wsrepublish', 'static'],
            http_repub=None, websocket_repub=None, mongo_repub=None, pg_repub=None):
    """Get the twisted site for smap-archiver"""
    root = RootResource(value={'Contents': resources})
    if not http_repub:
        http_repub = republisher.ReResource(db)
    if not websocket_repub:
        websocket_repub = republisher.WebSocketRepublishResource(db)

    def repub_fn(*args):
        dl = []
        if 'republish' in resources:
            http_repub.republish(*copy.deepcopy(args))
        if 'wsrepublish' in resources:
            websocket_repub.republish(*copy.deepcopy(args))
        if mongo_repub:
            dl.append(mongo_repub.republish(*copy.deepcopy(args)))
        if pg_repub:
            dl.append(pg_repub.republish(*copy.deepcopy(args)))
        return defer.DeferredList(dl, fireOnOneErrback=True)

    if 'republish' in resources:
        root.putChild('republish', http_repub)
    if 'wsrepublish' in resources:
        root.putChild('wsrepublish', websocket_repub)
    if 'add' in resources:
        root.putChild('add', DataResource(db, repub_fn))
    if 'api' in resources:
        root.putChild('api', api.Api(db))
    if 'static' in resources:
        root.putChild('static', static.File('static'))
    return server.Site(root)