コード例 #1
0
def uploadUserDataAndProjects(request):
    settings = settingsdb['settings']
    remote_url_doc = cachedb['remote_url']
    remote_url = remote_url_doc['value']
    #remote_projectsdb = settings['remote_projectsdb']
    #remote_usersdb = setttings['remote_usersdb']
    remote_usersdb = prooffer_settings.get('remote_usersdb')
    remote_projectsdb = prooffer_settings.get('remote_projectsdb')
    projectsdb = settings['projectsdb']
    usersdb = settings['usersdb']
    server.replicate(projectsdb,
                     insertUsernamePassword(remote_url) + remote_projectsdb)
    server.replicate(usersdb,
                     insertUsernamePassword(remote_url) + remote_usersdb)
    return render_to_response("status.html")
コード例 #2
0
def getUserPrivileges(request):
    response = {'app_url': prooffer_settings.get('app_url'), 'privileges': []}

    if len(usersdb) > 0:
        userid_doc = cachedb['userid']
        userid = userid_doc['value']
        if userid in usersdb:
            user = usersdb[userid]
            for privilege in user['privileges']:
                response['privileges'].append({
                    'name': datadb[privilege]['name'],
                    'id': privilege
                })

# file = open("aaaaaaa.txt", "w")
# file.write(prooffer_settings.get('test_datadb'))
# file.write(prooffer_settings.get('test_projectsdb'))
# file.write(prooffer_settings.get('test_usersdb'))
# file.close()

# file = open("bbbbbb.txt", "w")
# file.write(settingsdb['settings']['remote_datadb'])
# file.write(settingsdb['settings']['remote_usersdb'])
# file.write(settingsdb['settings']['remote_projectsdb'])
# file.close()

        return HttpResponse(json.dumps(response))
コード例 #3
0
def syncProofferUsersUpStream(request):
    settings = settingsdb['settings']
    remote_url_doc = cachedb['remote_url']
    remote_url = remote_url_doc['value']
    #remote_db = settings['remote_usersdb']
    remote_db = prooffer_settings.get('remote_usersdb')
    db = settings['usersdb']
    server.replicate(db, insertUsernamePassword(remote_url) + remote_db)
    return HttpResponse("OK")
コード例 #4
0
def updateProofferDataViews(request):
    settings = settingsdb['settings']
    remote_url_doc = cachedb['remote_url']
    remote_url = remote_url_doc['value']
    #remote_datadb = settings['remote_datadb']
    remote_datadb = prooffer_settings.get('remote_datadb')
    datadb = settings['datadb']
    server.replicate(insertUsernamePassword(remote_url) + remote_datadb,
                     datadb,
                     doc_ids=['_design/prooffer_data_views'])
    return render_to_response("status.html")
コード例 #5
0
def syncProofferProjectsDownStream(request):
    try:
        settings = settingsdb['settings']
        remote_url_doc = cachedb['remote_url']
        remote_url = remote_url_doc['value']
        #remote_db = settings['remote_projectsdb']
        remote_db = prooffer_settings.get('remote_projectsdb')
        db = settings['projectsdb']
        server.replicate(insertUsernamePassword(remote_url) + remote_db, db)
        return HttpResponse("OK")
    except Exception as error:
        raise
コード例 #6
0
def initSync(request):
    replicatordb = server['_replicator']

    def initialize(replicant, source, target):
        if replicant not in replicatordb:
            replicant_doc = {'source': source, 'target': target}
            replicant_doc.update(
                {'continuous': request.REQUEST['continuous'] == 'True'})
            replicant_doc.update(
                {'create_target': request.REQUEST['create_target'] == 'True'})
            replicatordb[replicant] = replicant_doc

        if request.REQUEST['cancel'] == 'True':
            if replicant in replicatordb:
                doc = replicatordb[replicant]
                replicatordb.delete(doc)

    settings = settingsdb['settings']
    remote_url_doc = cachedb['remote_url']
    remote_url = remote_url_doc['value']
    #remote_usersdb = settings['remote_usersdb']
    #remote_datadb = settings['remote_datadb']
    #remote_projectsdb = settings['remote_projectsdb']
    remote_usersdb = prooffer_settings.get('remote_usersdb')
    remote_projectsdb = prooffer_settings.get('remote_projectsdb')
    remote_datadb = prooffer_settings.get('remote_datadb')
    usersdb = settings['usersdb']
    datadb = settings['datadb']
    projectsdb = settings['projectsdb']

    initialize('prooffer_data',
               insertUsernamePassword(remote_url) + remote_datadb, datadb)
    initialize('prooffer_users',
               insertUsernamePassword(remote_url) + remote_usersdb, usersdb)
    initialize('prooffer_projects',
               insertUsernamePassword(remote_url) + remote_projectsdb,
               projectsdb)

    return render_to_response("status.html")
コード例 #7
0
def syncProofferDataDownStream(request):
    try:
        file = open("test.txt", "w")
        settings = settingsdb['settings']
        remote_url_doc = cachedb['remote_url']
        remote_url = remote_url_doc['value']
        file.write(remote_url)
        file.write(insertUsernamePassword(remote_url))
        #remote_datadb = settings['remote_datadb']
        remote_datadb = prooffer_settings.get('remote_datadb')
        datadb = settings['datadb']
        server.replicate(
            insertUsernamePassword(remote_url) + remote_datadb, datadb)
        return HttpResponse("OK")
    except:
        raise
    finally:
        file.close()
コード例 #8
0
import couchdb
import prooffer_settings

server = couchdb.Server()
projectsdb = server[prooffer_settings.get('projectsdb')]
usersdb = server[prooffer_settings.get('usersdb')]
datadb = server[prooffer_settings.get('datadb')]
admindatadb = server[prooffer_settings.get('admindatadb')]

isAdmin = False


def getServer():
    return server


def getProjectsDB():
    return projectsdb


def getUsersDB():
    return usersdb


def getDataDB():
    return datadb