Пример #1
0
request, response = current.request, current.response
from gluon.dal import DAL
import os

if 0:
    from gluon import URL

"""
# if SSL/HTTPS is properly configured and you want all HTTP requests to
# be redirected to HTTPS, uncomment the line below:
# request.requires_https()
"""

if current.request.is_local:
    from gluon.custom_import import track_changes
    track_changes()


def check_path(path):
    if os.path.exists(path):
        return path
    raise OSError(2, "{}: {}".format(os.strerror(2), path))

db = DAL('sqlite://storage.sqlite', fake_migrate=False, migrate=True)
current.db = db

# by default give a view/generic.extension to all actions from localhost
# none otherwise. a pattern can be 'controller/function.extension'
response.generic_patterns = ['*'] if request.is_local else []
# (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
Пример #2
0
import os, uuid
from cStringIO import StringIO
from gluon.custom_import import track_changes
from gluon.storage import Storage
track_changes()
ivy = local_import('ivy')
treebase = ivy.treebase
#from ivy import treebase
response.subtitle = "Studies"

class Virtual(object):
    def study_url(self):
        u = URL(c="study",f="view",args=[self.study.id],extension="")
        s = self.study.citation
        N = 50
        if len(s)>N: s = s[:N-3]+" ..."
        return A(s, _href=u, _title=self.study.citation)

    def trees(self):
        rows = db(db.stree.study==self.study.id).select()
        ul = DIV()
        for r in rows:
            a = A(r.type, _href=URL('stree','svgView',args=r.id,extension=''))
            ul.append(DIV(a))
        return ul.xml()

## def index():
##     t = db.study

##     class Virtual(object):
##         @virtualsettings(label='Citation')
Пример #3
0
# -*- coding: utf-8 -*-

DEBUG = True

from gluon import current

# track changes for modules
from gluon.custom_import import track_changes
track_changes(DEBUG)

# set utc as standard time for app
request.now = request.utcnow

if request.global_settings.web2py_version < "2.14.1":
    raise HTTP(500, "Requires web2py 2.14.1 or newer")

# request.requires_https()

# application configuration using private/appconfig.ini
from gluon.contrib.appconfig import AppConfig
myconf = AppConfig(reload=DEBUG)
current.myconf = myconf
myconf_env = myconf.get('environment.type')
current.myconf_env = myconf_env

# set db connection
if not request.env.web2py_runtime_gae:
    # if NOT running on Google App Engine use SQLite or other DB
    db = DAL(
        myconf.get(myconf_env + 'db.uri'),
        pool_size=myconf.get(myconf_env + 'db.pool_size'),
Пример #4
0
              'templates_dir'  : 'vm_templates',
              'archives_dir'   : 'vm_archives',
              'vmcount'        :  1,
              'admin_email'    : '*****@*****.**' }

current.ADMIN = ADMIN
current.ORGADMIN = ORGADMIN
current.FACULTY = FACULTY
current.USER = USER

MAC_IP_POOL = { '54:52:00:01:17:89' : '10.208.21.75',
                '54:52:00:01:17:88' : '10.208.21.76',
                '54:52:00:01:17:87' : '10.208.21.77',
                '54:52:00:01:17:86' : '10.208.21.78',
                '54:52:00:01:17:85' : '10.208.21.79',
                '54:52:00:01:17:84' : '10.208.21.80',
                '54:52:00:01:17:83' : '10.208.21.81',
                '54:52:00:01:17:82' : '10.208.21.82',
                '54:52:00:01:17:81' : '10.208.21.83',
                '54:52:00:01:17:80' : '10.208.21.84',
                '54:52:00:01:17:79' : '10.208.21.86',
                '54:52:00:01:17:78' : '10.208.21.87',
                '54:52:00:01:17:77' : '10.208.21.88',
                '54:52:00:01:17:76' : '10.208.21.89' } 

current.MAC_IP_POOL = MAC_IP_POOL

ITEMS_PER_PAGE=20
#Added so that changes in modules are instantlly loaded and reflected.
from gluon.custom_import import track_changes; track_changes(True)
Пример #5
0
# -*- coding: utf-8 -*-

import datetime

from plugin_mz import link


if request.is_local:
    from gluon.custom_import import track_changes
    track_changes(True)    # auto-reload modules
elif request.is_https:
    session.secure()

link('css/w3.css')
Пример #6
0
# -*- coding: utf-8 -*-

from gluon.custom_import import track_changes; track_changes(True) # for reloading modules

#########################################################################
## This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations
#########################################################################

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request.env.web2py_runtime_gae:
    ## if NOT running on Google App Engine use SQLite or other DB
    db = DAL('sqlite://storage.sqlite')
else:
    ## connect to Google BigTable (optional 'google:datastore://namespace')
    db = DAL('google:datastore')
    ## store sessions and tickets there
    session.connect(request, response, db=db)
    ## or store session in Memcache, Redis, etc.
    ## from gluon.contrib.memdb import MEMDB
    ## from google.appengine.api.memcache import Client
    ## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'

# Luca says: do NOT make generic json possible, as there is information that should
# not leak out in most forms.
Пример #7
0
T.force('es-es')

settings = Storage()

settings.produccion = True

if settings.produccion == True:
    settings.expiracion = 60 * 60  # logout after 5 minutes of inactivity
else:
    settings.expiracion = 60 * 60

if settings.produccion:
    settings.db_uri = 'mysql://*****:*****@mysql/datosies'   
    settings.migrate = False
    settings.log_level = logging.ERROR   
    track_changes(False)
else:
    settings.db_uri = 'mysql://*****:*****@mysql/datosiesdev'
    settings.migrate = True
    settings.log_level = logging.DEBUG
    track_changes(True)
    

#
# Logger
#
def get_configured_logger(name):
    logger = logging.getLogger(name)
    if (len(logger.handlers) == 0):
        # Create RotatingFileHandler
        import os
Пример #8
0
settings.author_email = config.settings['author_email']
settings.keywords = config.settings['keywords']
settings.description = config.settings['description']
settings.mysql_uri = config.settings['mysql_uri']

settings.email_server = config.settings['email_server']
settings.email_sender = config.settings['email_sender']
settings.email_login = config.settings['email_login']
settings.login_method = config.settings['login_method']
settings.login_config = config.settings['login_config']
settings.plugins = config.settings['plugins']
settings.prelaunch = True

if request.is_local:
    from gluon.custom_import import track_changes
    track_changes(True)
import datetime

response.generic_patterns = ['*'] if request.is_local else []
## (optional) optimize handling of static files
#response.optimize_css = 'concat,minify,inline'
#response.optimize_js = 'concat,minify,inline'
response.optimize_css = 'concat,minify'
response.optimize_js = 'concat,minify'
#response.static_version = '0.0.1'
#response.static_version

import sys, os
from gluon.fileutils import abspath

#85.56.86.237  ip nueva de jose
Пример #9
0
# -*- coding: utf-8 -*-
from gluon.custom_import import track_changes; track_changes(True) #todo: raus, wenn man online geht.
#########################################################################
## This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations
#########################################################################

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request.env.web2py_runtime_gae:
    ## if NOT running on Google App Engine use SQLite or other DB
    db = DAL('sqlite://storage.sqlite')
else:
    ## connect to Google BigTable (optional 'google:datastore://namespace')
    db = DAL('google:datastore')
    ## store sessions and tickets there
    session.connect(request, response, db = db)
    ## or store session in Memcache, Redis, etc.
    ## from gluon.contrib.memdb import MEMDB
    ## from google.appengine.api.memcache import Client
    ## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'
response.generic_patterns = ['*'] if request.is_local else []
## (optional) optimize handling of static files
# response.optimize_css = 'concat,minify,inline'
# response.optimize_js = 'concat,minify,inline'
Пример #10
0
Файл: db.py Проект: tazjel/gdms
if useappconfig:
    from gluon.contrib.appconfig import AppConfig
    # once in production, remove reload=True to gain full speed
    myconf = AppConfig(reload=False)
    debug = myconf.take('developer.debug', cast=int)
    backend = myconf.take('search.backend')
    # removed as now set on pythonanywhere
    #if myconf.take('site.require_https', cast=int):
    #    request.requires_https()
else:
    debug = False
    backend = 'SimpleBackend'

# once in production change to False
track_changes(debug)
response.static_version = '2.0.0'

if not request.env.web2py_runtime_gae:
    if useappconfig:
        db = DAL(myconf.take('db.uri'),
                 pool_size=myconf.take('db.pool_size', cast=int),
                 migrate=myconf.take('db.migrate', cast=int),
                 fake_migrate_all=False, # this seems quite flaky
                 lazy_tables=myconf.take('db.lazy_tables', cast=int),
                 check_reserved=['all'])
    else:
        db = DAL('sqlite://storage.sqlite')
else:
    db = DAL('google:datastore+ndb')
    # store sessions and tickets there
Пример #11
0
def podersearch():
    from gluon.custom_import import track_changes; track_changes(True)
    import sphinxapi
    import fsphinx
    #from fsphinx import *
    from fsphinx.facets import Facet
    from fsphinx.hits import DBFetch, SplitOnSep
    from fsphinx.sphinx import FSphinxClient
    from fsphinx.cache import RedisCache
    #from fsphinx.utils import storage

    from fsphinx.queries import QueryParser, MultiFieldQuery
    #from gluon.contrib.redis_cache import RedisCache

    searchquery="chile"
    if request.vars['search']: searchquery=request.vars['search']
    filter=request.vars['filter']
    term=request.vars['term']

    #'@year 1999 @genre drama @actor harrison ford'
    queryEmpresas='@empresas '+searchquery.decode('utf-8')
    queryOrgs='@organizaciones '+searchquery.decode('utf-8')
    #queryEmpresas=None; queryOrgs=None;
    query=searchquery.decode('utf-8')
    if (filter!=None) & (term!=None):
        query=(query+' @'+filter+' '+term.decode('utf-8'))
        queryEmpresas=queryEmpresas+' @'+filter+' '+term.decode('utf-8')
        #queryEmpresas='@'+filter+' '+term.decode('utf-8')
        queryOrgs=queryOrgs+' @'+filter+' '+term.decode('utf-8')
        #queryOrgs='@'+filter+' '+term.decode('utf-8')
    ##
    ##cl = FSphinxClient.FromConfig('c:\web2py2\web2py\applications\poderopedia\private\sphinx_client.py')




    # let's have a cache for later use
    #cache = RedisCache(db=0)

    # show output of mysql statements
    #db2.printing = False

    # create sphinx client
    cl = FSphinxClient()

    # connect to searchd
    cl.SetServer('localhost', 9312)

    # matching mode (faceted client should be SPH_MATCH_EXTENDED2)
    #cl.SetRankingMode ( sphinxapi.SPH_RANK_PROXIMITY_BM25 )
    # matching mode (faceted client should be SPH_MATCH_EXTENDED2)
    cl.SetMatchMode(sphinxapi.SPH_MATCH_EXTENDED2)

    # sorting and possible custom sorting function
    #cl.SetSortMode(sphinxapi.SPH_SORT_EXPR, '@weight * user_rating_attr * nb_votes_attr * year_attr / 100000')

    # set the default index to search
    cl.SetDefaultIndex('items')

    # some fields could matter more than others
    cl.SetFieldWeights({'alias' : 30})
    cl.SetFieldWeights({'empresas' : 30})
    cl.SetFieldWeights({'organizaciones' : 30})

    # some fields could matter more than others
    #   cl.SetFieldWeights({'alias' : 30})

    #

    # sql query to fetch the hits
    db_fetch = DBFetch(db, sql = '''
        select id, ICN, firstName, firstLastName, otherLastName, alias, shortBio, longBio, isDead, web, twitterNick, facebookNick, linkedinNick,
        (select group_concat(distinct name separator '@#@') from country c where c.id=p.countryofResidence) as pais,
        (select group_concat(distinct relationship separator '@#@') from RelPersOrg as r, tipoRelacionP20 as t where r.origenP=p.id and r.specificRelation=t.id and t.generalizacion='Propiedad' and r.is_active='T') as propiedad,
        (select group_concat(distinct relationship separator '@#@') from RelPersOrg as r, tipoRelacionP20 as t where r.origenP=p.id and r.specificRelation=t.id and t.generalizacion is null and t.parent=3 and r.is_active='T') as cargos_gobierno,
        (select group_concat(distinct relationship separator '@#@') from RelPersOrg as r, tipoRelacionP20 as t where r.origenP=p.id and r.specificRelation=t.id and t.generalizacion is null and t.parent!=3 and t.parent!=1 and t.parent!=4 and parent!=11 and r.is_active='T') as cargos_trabajo,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg!=2 and o.tipoOrg!=1 and o.tipoOrg!=1 and o.tipoOrg!=4 and o.tipoOrg!=5 and o.tipoOrg!=6 and o.tipoOrg!=8 and r.is_active='T' and o.is_active='T') as organizaciones,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg=1 and r.is_active='T' and o.is_active='T') as estudios,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg=2 and r.is_active='T' and o.is_active='T') as empresas,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg=4 and r.is_active='T' and o.is_active='T') as partidos,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg=5 and r.is_active='T' and o.is_active='T') as religion,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg=6 and r.is_active='T' and o.is_active='T') as clubes,
        (select group_concat(distinct o.alias separator '@#@') from RelPersOrg as r, Organizacion as o where r.origenP=p.id and r.destinoO=o.id and o.tipoOrg=8 and r.is_active='T' and o.is_active='T') as grupos_apoyo,
        (select group_concat(distinct s.alias separator '@#@') from relPersona as r, tipoRelacionP2P as t, persona as s where r.origenP=p.id and r.destinoP=s.id and r.relacion=t.id and t.parent=1) as conyuge,
        (select group_concat(distinct s.alias separator '@#@') from relPersona as r, tipoRelacionP2P as t, persona as s where r.origenP=p.id and r.destinoP=s.id and r.relacion=t.id and t.parent!=1) as relacion_persona,
        (select group_concat(distinct s.alias separator '@#@') from relFamiliar as r, persona as s where r.origenP=p.id and r.destinoP=s.id) as relacion_familiar
        from persona p
        where p.is_active='T' and id in ($id)
        order by field(id, $id)''', post_processors = [
        SplitOnSep('pais','propiedad','cargos_gobierno','cargos_trabajo','organizaciones','estudios','empresas','partidos','religion','clubes','grupos_apoyo','conyuge','relacion_persona','relacion_familiar',sep='@#@')
    ]
    )
    cl.AttachDBFetch(db_fetch)

    pais=Facet('pais', attr='pais_attr', sql_col='name', sql_table='country')
    propiedad=Facet('propiedad', attr='propiedad_attr', sql_col='relationship', sql_table='tipoRelacionP20')
    cargos_gobierno=Facet('cargos_gobierno', attr='cargos_gobierno_attr', sql_col='relationship', sql_table='tipoRelacionP20')
    cargos_trabajo=Facet('cargos_trabajo', attr='cargos_trabajo_attr', sql_col='relationship', sql_table='tipoRelacionP20')
    organizaciones=Facet('organizaciones', attr='organizaciones_attr', sql_col='alias', sql_table='Organizacion')
    estudios=Facet('estudios', attr='estudios_attr', sql_col='alias', sql_table='Organizacion')
    empresas=Facet('empresas', attr='empresas_attr', sql_col='alias', sql_table='Organizacion')
    partidos=Facet('partidos', attr='partidos_attr', sql_col='alias', sql_table='Organizacion')
    religion=Facet('religion', attr='religion_attr', sql_col='alias', sql_table='Organizacion')
    clubes=Facet('clubes', attr='clubes_attr', sql_col='alias', sql_table='Organizacion')
    grupos_apoyo=Facet('grupos_apoyo', attr='grupos_apoyo_attr', sql_col='alias', sql_table='Organizacion')
    conyuge=Facet('conyuge', attr='conyuge_attr', sql_col='alias', sql_table='persona')
    relacion_persona=Facet('relacion_persona', attr='relacion_persona_attr', sql_col='alias', sql_table='persona')
    relacion_familiar=Facet('relacion_familiar', attr='relacion_familiar_attr', sql_col='alias', sql_table='persona')

    # setup the different facets
    cl.AttachFacets(
        organizaciones,
        empresas,
        pais,
        propiedad,
        cargos_gobierno,
        cargos_trabajo,
        estudios,
        partidos,
        religion,
        clubes,
        grupos_apoyo,
        conyuge,
        relacion_persona,
        relacion_familiar,
    )

    # give it a cache for the search and the facets
    #cl.AttachCache(cache)



    # for all facets compute count, groupby and this score


    # setup sorting and ordering of each facet
    for f in cl.facets:
        #f.SetGroupFunc(group_func)
        # order the term alphabetically within each facet
        #f.SetOrderBy('@term')
        f.SetOrderBy('@count')

    # the query should always be parsed beforehand
    query_parser = QueryParser(MultiFieldQuery, user_sph_map={
        'organizaciones':'organizaciones',
        'empresas':'empresas',
        'pais':'pais',
        'propiedad':'propiedad',
        'cargos_gobierno':'cargos_gobierno',
        'cargos_trabajo':'cargos_trabajo',
        'estudios':'estudios',
        'partidos':'partidos',
        'religion':'religion',
        'clubes':'clubes',
        'grupos_apoyo':'grupos_apoyo',
        'organizaciones' : 'organizaciones',
        'empresas' : 'empresas',
        'conyuge': 'conyuge',
        'relacion_persona': 'relacion_persona',
        'relacion_familiar':'relacion_familiar',
    })
    cl.AttachQueryParser(query_parser)


    ##cl.SetSortMode(sphinxapi.SPH_SORT_RELEVANCE)
    ##cl.AddQuery(searchquery,'organizaciones')
    ##cl.AddQuery(searchquery,'empresas')
    ##cl.AddQuery(searchquery,'relacion_empresa')
    ##cl.AddQuery(searchquery,'relacion_persona')
    ##cl.AddQuery(searchquery,'relacion_familiar')
    ##resultsAll=cl.RunQueries()

    addEmpresa=[]
    if queryEmpresas:
        cl.Query(queryEmpresas)
        hits=cl.hits
        if hits.total_found>0:
            for empresa in empresas:
                if empresa['@selected']==True:
                    emp=db.Organizacion(empresa['@groupby'])
                    imagen=emp.haslogo
                    if imagen:
                        html=IMG(_src=URL('download',args=imagen),_alt=emp.alias,_width="50")
                    else:
                        html=IMG(_src=URL('static','tmp/avatarempresa.png'),_alt=emp.alias, _width="50")
                    addEmpresa.append(dict(id=empresa['@groupby'],alias=emp.alias,picture=html))

    if queryOrgs:
        cl.Query(queryOrgs)
        hits=cl.hits
        if hits.total_found>0:
            for org in organizaciones:
                if org['@selected']==True:
                    organiz=db.Organizacion(org['@groupby'])
                    imagen=organiz.haslogo
                    if imagen:
                        html=IMG(_src=URL('download',args=imagen),_alt=organiz.alias,_width="50")
                    else:
                        html=IMG(_src=URL('static','img/icono-organizaciones.png'),_alt=organiz.alias, _width="50")
                    addEmpresa.append(dict(id=org['@groupby'],alias=organiz.alias,picture=html))

    #hits = db_fetch.Fetch(results)
    cl.Query(query)
    results=cl.query
    facets=cl.facets
    hits=cl.hits
    person={}
    for match in hits:
        if '@hit' in match:
            persona=db.persona(match['@hit']['id'])
            imagen=persona.depiction
            if imagen:
                html=IMG(_src=URL('download',args=imagen),_alt=match['@hit']['alias'],_width="50")
            else:
                html=IMG(_src=URL('static','tmp/avatar-45.gif'),_alt=match['@hit']['alias'])
            person[match['@hit']['id']]=html

    items_per_page=19
    letter='0'

    nomFacetas=['Organizaciones','Empresas','Pais','Propiedad','Cargos de Gobierno','Cargos Privados','Estudios','Partidos','Religion','Clubes Privados','Grupos de Apoyo','Conyuge','Amigos y Conocidos','Familiar']




    return dict(addEmpresa=addEmpresa,searchquery=searchquery, nomFacetas=nomFacetas, results=results,facets=facets,hits=hits,_id=1,page=0, sort=0, target=0, entity=[1],items_per_page=items_per_page,letter=letter, person=person)
Пример #12
0
def facetedsearch():
    from gluon.custom_import import track_changes; track_changes(True)
    import sphinxapi
    import fsphinx
    from fsphinx.sphinx import FSphinxClient
    from fsphinx.cache import RedisCache
    import fsphinx.utils
    from fsphinx.facets import Facet
    from fsphinx.queries import QueryParser, MultiFieldQuery
    #from gluon.contrib.redis_cache import RedisCache

    searchquery=request.args(0)

    ##
    ##cl = FSphinxClient.FromConfig('c:\web2py2\web2py\applications\poderopedia\private\sphinx_client.py')


    #import MySQLdb
    #import web


    #from fsphinx import FSphinxClient, Facet, DBFetch, SplitOnSep
    #from fsphinx import QueryParser, MultiFieldQuery, RedisCache

    # connect to database
    #data = web.database(dbn='mysql', db='powertest', user='******', passwd='mobutu')

    # let's have a cache for later use
    cache = RedisCache(db=0)

    # show output of mysql statements
    #db2.printing = False

    # create sphinx client
    cl = FSphinxClient()

    # connect to searchd
    cl.SetServer('localhost', 9312)

    # matching mode (faceted client should be SPH_MATCH_EXTENDED2)
    cl.SetMatchMode(sphinxapi.SPH_MATCH_EXTENDED2)

    # sorting and possible custom sorting function
    #cl.SetSortMode(sphinxapi.SPH_SORT_EXPR, '@weight * user_rating_attr * nb_votes_attr * year_attr / 100000')

    # set the default index to search
    cl.SetDefaultIndex('items')

    # some fields could matter more than others
    cl.SetFieldWeights({'alias' : 30})
    cl.SetFieldWeights({'empresas' : 30})
    cl.SetFieldWeights({'organizaciones' : 30})

    ##cl.AttachDBFetch(db)


    # give it a cache for the search and the facets
    #cl.AttachCache(cache)

    organizaciones=Facet('organizaciones', attr='organizacion_attr', sql_col='alias', sql_table='Organizacion')
    empresas=Facet('empresas', attr='empresa_attr', sql_col='alias', sql_table='Organizacion')
    relacion_empresa=Facet('relacion_empresa', attr='relacionEmp_attr', sql_col='relationship', sql_table='tipoRelacionP20')
    relacion_persona=Facet('relacion_persona', attr='relacionPers_attr', sql_col='alias', sql_table='persona')
    relacion_familiar=Facet('relacion_familiar', attr='relacionFam_attr', sql_col='alias', sql_table='persona')

    organizaciones.AttachSphinxClient(cl, db)
    empresas.AttachSphinxClient(cl,db)
    relacion_empresa.AttachSphinxClient(cl,db)
    relacion_persona.AttachSphinxClient(cl,db)
    relacion_familiar.AttachSphinxClient(cl,db)

    # setup the different facets
    #cl.AttachFacets(
    #    organizaciones,
    #    empresas,
    #    relacion_empresa,
    #    relacion_persona,
    #    relacion_familiar,
    #)

    # for all facets compute count, groupby and this score


    # setup sorting and ordering of each facet
    for f in cl.facets:
        #f.SetGroupFunc(group_func)
        # order the term alphabetically within each facet
        f.SetOrderBy('@term')

    # the query should always be parsed beforehand
    query_parser = QueryParser(MultiFieldQuery, user_sph_map={
        'organizaciones' : 'organizacion',
        'empresas' : 'empresa',
        'relacion_empresa' : 'cargos',
        'relacion_persona' : 'personas_relacionadas',
        'relacion_familiar' : 'familiares'
    })
    cl.AttachQueryParser(query_parser)

    cl.SetSortMode(sphinxapi.SPH_SORT_RELEVANCE)
    cl.Query(searchquery)
    cl.AddQuery(searchquery,'organizaciones')
    cl.AddQuery(searchquery,'empresas')
    cl.AddQuery(searchquery,'relacion_empresa')
    cl.AddQuery(searchquery,'relacion_persona')
    cl.AddQuery(searchquery,'relacion_familiar')
    resultsAll=cl.RunQueries()
    results=cl.query
    facets=cl.facets
    hits=cl.hits

    return dict(results=results,facets=facets,hits=hits,resultsAll=resultsAll,_id=1,page=0, sort=0, target=0, entity=0)
Пример #13
0
# -*- coding: utf-8 -*-

from gluon.tools import Auth, Mail
from gluon.custom_import import track_changes


##################################################
### Set DEBUG
##################################################
DEBUG = request.is_local


##################################################
### Reload modules
##################################################
track_changes(DEBUG)


##################################################
### Database config
##################################################
if DEBUG:     
    db = DAL('sqlite://storage.sqlite')
else:
    db = DAL('postgres://*****:*****@localhost:5432/database')


##################################################
### Mail settings
##################################################
mail = Mail()      
Пример #14
0
# -*- coding: utf-8 -*-
#reload modules
from gluon.custom_import import track_changes; track_changes(True)
import opettaja  #tietokantahaut ../modules/opettaja.py

#import opettajan_haut #../models/opettajan_haut.py

@auth.requires_membership('opettaja')
def kaikki_kurssit():
    """
    Opettajan kaikki kurssit
    """
    import sys

    opettajan_kurssit = opettaja.hae_opettajan_kaikki_kurssit(db)
    oppilaita_kurssilla = []
    #tehdään fake-database käyttäen haettujen kurssien nimiä
    #jotta saadaan ne alasvetovalikkoon
    db.define_table('valitsekurssi',
                    Field('kurssin_nimi'),
                    format = '%(kurssin_nimi)s'
                    )
    kurssi_idt = []
    for rivi in opettajan_kurssit:
        db.valitsekurssi.insert(kurssin_nimi=rivi.kurssi.title)
        print rivi.kurssi.id
        kurssi_idt.append(rivi.kurssi.id)

    form = SQLFORM.factory(
        Field('kurssin_nimi', requires=IS_IN_DB(db, 
                                        db.valitsekurssi.id,
Пример #15
0
"""
This is the document controller
 - contribute
 - review

"""

from gluon.custom_import import track_changes; track_changes(True) #enable tracking changes of modules
from bootstrap_widget import BootstrapRadio

def view():
    # Get document or redirect
    try:
        doc = db.doc(request.args(0,cast=int))
        if doc is None:
            raise LookupError
    except:
        redirect(request.env.http_referer)

    # Get fields for the document's project
    fields = db(db.field.project==doc.project.id).select()
    # Get ids of contributions for the doc
    contributions = db(db.contribution.doc == doc.id).select()

    for item in fields:
        # Get accepted metadata for each field
        item.metadata = db((db.metadata.contribution.belongs(contributions)) & (db.metadata.field == item.id) & (db.metadata.status == 2)).select().first()

    response.title = doc.name + ' (' + doc.project.title + ')'
    response.subtitle = 'View'
Пример #16
0
# -*- coding: utf-8 -*-

from gluon.custom_import import track_changes
track_changes(True)  # for reloading modules

#########################################################################
## This scaffolding model makes your app work on Google App Engine too
## File is released under public domain and you can use without limitations
#########################################################################

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
# request.requires_https()

if not request.env.web2py_runtime_gae:
    ## if NOT running on Google App Engine use SQLite or other DB
    db = DAL('sqlite://storage.sqlite')
else:
    ## connect to Google BigTable (optional 'google:datastore://namespace')
    db = DAL('google:datastore')
    ## store sessions and tickets there
    session.connect(request, response, db=db)
    ## or store session in Memcache, Redis, etc.
    ## from gluon.contrib.memdb import MEMDB
    ## from google.appengine.api.memcache import Client
    ## session.connect(request, response, db = MEMDB(Client()))

## by default give a view/generic.extension to all actions from localhost
## none otherwise. a pattern can be 'controller/function.extension'

# Luca says: do NOT make generic json possible, as there is information that should
Пример #17
0
# -*- coding: utf-8 -*-

import datetime

from mzm import PP, accept, link
link('js/mz/mzj', 'css/mz/mzc')

## if SSL/HTTPS is properly configured and you want all HTTP requests to
## be redirected to HTTPS, uncomment the line below:
if request.is_local:
    from gluon.custom_import import track_changes
    track_changes(True)  # auto-reload modules
#else:
#    request.requires_https()
Пример #18
0
    Instantiate Classes
"""

if settings.get_L10n_languages_readonly():
    # Make the Language files read-only for improved performance
    T.is_writable = False

# Are we running in debug mode?
s3.debug = request.vars.get("debug", None) or \
                    settings.get_base_debug()

if s3.debug:
    # Reload all modules every request
    # Doesn't catch s3cfg or s3/*
    from gluon.custom_import import track_changes
    track_changes(True)

import datetime

try:
    import json # try stdlib (Python 2.6)
except ImportError:
    try:
        import simplejson as json # try external module
    except:
        import gluon.contrib.simplejson as json # fallback to pure-Python module

########################
# Database Configuration
########################
Пример #19
0
# -*- coding: utf-8 -*-
print('================================================ APPLICATION STARTED ================================================')

# -------------------------------------------------------------------------
# AppConfig configuration made easy. Look inside private/appconfig.ini
# Auth is for authenticaiton and access control
# -------------------------------------------------------------------------
from gluon.contrib.appconfig import AppConfig
from gluon.tools import Auth
from gluon.custom_import import track_changes; track_changes(True)  # Imports changes to my custom modules
from gluon import current  # This is needed to make db available in modules that I import. See https://stackoverflow.com/questions/11959719/web2py-db-is-not-defined

# -------------------------------------------------------------------------
# This scaffolding model makes your app work on Google App Engine too
# File is released under public domain and you can use without limitations
# -------------------------------------------------------------------------

if request.global_settings.web2py_version < "2.15.5":
    raise HTTP(500, "Requires web2py 2.15.5 or newer")

# -------------------------------------------------------------------------
# if SSL/HTTPS is properly configured and you want all HTTP requests to
# be redirected to HTTPS, uncomment the line below:
# -------------------------------------------------------------------------
# request.requires_https()

# -------------------------------------------------------------------------
# once in production, remove reload=True to gain full speed
# -------------------------------------------------------------------------
configuration = AppConfig(reload=True)