def configure(self, force_test_db=False): if DEBUG is None: self.debug = config.get("database.debug", "").lower() == "true" else: self.debug = DEBUG if force_test_db: logg.warn("WARNING: force_test_db requested, creating / using test database server", trace=False) test_db = True else: test_db = config.get("database.test_db", "false").lower() == "true" if test_db: logg.warn("WARNING: database.test_db enabled in config, creating / using test database server", trace=False) self.test_db = test_db if not test_db: self.host = config.get("database.host", "localhost") self.port = config.getint("database.port", "5432") self.database = config.get("database.db", "mediatum") self.user = config.get("database.user", "mediatum") self.passwd = config.get("database.passwd", "mediatum") self.pool_size = config.getint("database.pool_size", 20) self.slow_query_seconds = config.getfloat("database.slow_query_seconds", 0.2) self.application_name = "{}({})".format(os.path.basename(sys.argv[0]), os.getpid()) self.connectstr = CONNECTSTR_TEMPLATE.format(**self.__dict__) logg.info("using database connection string: %s", CONNECTSTR_TEMPLATE_WITHOUT_PW.format(**self.__dict__))
def __init__(self, req, list): self.req = req self.path = req.path[1:] self.language = lang(req) self.stdVars = getAdminStdVars(self.req) # self.page = 0 or None -> all entries try: self.page = int(req.params.get("page", req.params.get("actpage", 1))) except ValueError: self.page = req.params.get("actpage") if "firstpage" in req.params.keys(): self.page = 1 elif "resetpage" in req.params.keys(): self.page = 0 items_per_page = config.getint("admin.pageitems", 20) max_page = len(list) / items_per_page if max_page + 1 < self.page: self.page = 1 req.params["page"] = 1 if self.page == 0: self.start = 0 self.end = len(list) else: self.start = (self.page - 1) * items_per_page self.end = self.start + items_per_page self.list = list
def __init__(self, req, list): self.req = req self.path = req.path[1:] self.language = lang(req) self.stdVars = getAdminStdVars(self.req) # self.page = 0 or None -> all entries try: self.page = int( req.params.get("page", req.params.get("actpage", 1))) except ValueError: self.page = req.params.get("actpage") if "firstpage" in req.params.keys(): self.page = 1 elif "resetpage" in req.params.keys(): self.page = 0 items_per_page = config.getint("admin.pageitems", 20) max_page = len(list) / items_per_page if max_page + 1 < self.page: self.page = 1 req.params["page"] = 1 if self.page == 0: self.start = 0 self.end = len(list) else: self.start = (self.page - 1) * items_per_page self.end = self.start + items_per_page self.list = list
def getNoPages(self): return int(math.ceil(float(len(self.list)) / config.getint("admin.pageitems", 20)))
from itertools import izip_longest from sqlalchemy import Unicode, Float, Integer from utils.xml import xml_remove_illegal_chars from core.nodecache import get_collections_node, get_home_root_node import core.oauth as oauth from core.search.config import get_service_search_languages from array import array from core.request_handler import get_header as _get_header from core.request_handler import sendAsBuffer as _sendAsBuffer, sendFile as _sendFile logg = logging.getLogger(__name__) q = db.query configured_host = config.get("host.name", "") allow_cross_origin = config.getboolean("services.allow_cross_origin", False) DEFAULT_CACHE_VALID = config.getint("services.default_cache_valid", 0) from web.services.cache import Cache from web.services.cache import date2string as cache_date2string resultcache = Cache(maxcount=25, verbose=True) SEND_TIMETABLE = False DEFAULT_NODEQUERY_LIMIT = config.getint("services.default_limit", 1000) def add_mask_xml(xmlroot, node, mask_name, language): # mask handling if mask_name not in ["", "none"]: # deliver every mask if mask_name == 'default':
def getNoPages(self): return int( math.ceil( float(len(self.list)) / config.getint("admin.pageitems", 20)))