return Response(mylookup.get_template(template).render(**context), mimetype='text/html', headers=[('Pragma', 'no-store, no-cache'), ('Cache-control', 'no-store, no-cache, must-revalidate')]) # don't use this key but a different one; you could just use # os.unrandom(20) to get something random. Changing this key # invalidates all sessions at once. SECRET_KEY = '}zJg\xc7\xc0\x98\xaf\x00\xcb\xae=WRa\x99\x7f(\xce\xb7' # the cookie name for the session COOKIE_NAME = 'session' ADMINS = get_config_var('pycwb.admins') class AppRequest(Request): """A request with a secure cookie session.""" def logout(self): """Log the user out.""" self.session.pop('username', None) def login(self, username): """Log the user in.""" self.session['username'] = username self.session['real_user'] = username def become(self, username): if (self.session['real_user'] == username
# PyCWB annotation tool (c) 2009-2013 Yannick Versley / Univ. Tuebingen # released under the Apache license, version 2.0 # # This file provides access to a list of installed corpora. # The corpus_urls dictionary in this module maps each corpus name # to a function that turns text_id attribute values into a URL where # the source text can be found. # from app_configuration import get_config_var allowed_corpora_nologin = get_config_var('pycwb.corpora.nologin') allowed_corpora = allowed_corpora_nologin + get_config_var( 'pycwb.corpora.login') allowed_corpora_admin = allowed_corpora + get_config_var('pycwb.corpora.admin') tueba_url_pattern = get_config_var( 'pycwb.urls.tueba') + '/19%s/%s/%s/art%03d.htm' def compute_url_tueba(text_id, unused_corpus): year = text_id[1:3] month = text_id[3:5] day = text_id[5:7] artno = int(text_id[8:]) return tueba_url_pattern % (year, month, day, artno) parser_ordering_de = ['release', 'tueba'] corpus_sattr = {} corpus_d_sattr = {}
import re import sys import datetime from itertools import izip from collections import defaultdict from werkzeug import Response, redirect, escape import simplejson as json from app_configuration import get_config_var from webapp_admin import render_template, Forbidden, ADMINS from annodb.database import login_user, get_corpus, \ default_database, get_database, get_times, add_time from annodb.corpora import allowed_corpora_nologin, allowed_corpora try: default_annotator = get_config_var('pycwb.sense_edit.default_annotator') except KeyError: default_annotator = None try: gwn_dbname = get_config_var('pycwb.sense_edit.db') except KeyError: gwn_dbname = None filters = { 'N': set(['NN']), 'A': set(['ADJA', 'ADJD']), 'V': set(['VVFIN', 'VVINF', 'VVPP', 'VVIZU']), 'R': ['ADV'] }
LexicalUnit.orth_form == word) ] self.synsetsByWord[word] = result return result def synset_by_id(self, id): return self.session.query(Synset).get(id) def get_hypernym_graph(self): if self.hypernym_graph is None: self.hypernym_graph = HypernymGraph(self) return self.hypernym_graph def get_max_synset_id(self): result = self.session.execute('SELECT max(id) FROM synset_table') (max_synsetId, ) = result.fetchone() return max_synsetId dbs = {} db_urls = {} data_dirs = {} for k, v in get_config_var('germanet').iteritems(): db_urls[k] = v['db_server'] def get_database(name): if name not in dbs: dbs[name] = GWN_DB(db_urls[name]) return dbs[name]
import re import os.path import datetime import CWB.CL as cwb import pymongo import hashlib from app_configuration import get_config_var from passlib.hash import fshp from corpora import corpus_d_sattr, parse_order couch_ignore_attributes = set( ['_id', '_rev', 'type', 'span', 'corpus', 'annotator', 'level', 'word']) try: mongo_url = get_config_var('pycwb.mongodb.url') srv = pymongo.MongoClient(mongo_url) except KeyError: srv = pymongo.MongoClient('localhost', 27017) try: cwb_registry_dir = get_config_var('pycwb.cwb_registry') except KeyError: cwb_registry_dir = None try: username = get_config_var('pycwb.mongodb.username') password = get_config_var('pycwb.mongodb.password') except KeyError: username = None password = None