Beispiel #1
0
def get_relation_strength(name, tag_assoc):
    if (name == tag_assoc.to_):
        other = db(db.tags.name == tag_assoc.from_).select().first()
    elif (name == tag_assoc.from_):
        other = db(db.tags.name == tag_assoc.to_).select().first()
    else: return 0
    return 100 * tag_assoc.num / other.num
Beispiel #2
0
def get_tag_events(tag):
    if tag == None:
        return []
    entries = db((db.events.tags.contains(tag, all=False))).select()
    result = []
    for e in entries:
        result.append(e)
    return result
Beispiel #3
0
def get_tag_conflicts(tag, rel_str, start, end):
    entries = db(db.events.tags.contains(tag)).select()
    result = []
    start = datetime.strptime(str(start), "%Y-%m-%d %H:%M:%S").timetuple()
    end = datetime.strptime(str(end), "%Y-%m-%d %H:%M:%S").timetuple()
    for e in entries:
        e_start = datetime.strptime(str(e.start_time), "%Y-%m-%d %H:%M:%S").timetuple()
        e_end = datetime.strptime(str(e.end_time), "%Y-%m-%d %H:%M:%S").timetuple()
        ex1 = bool(e_start > start)
        ex2 = bool(end > e_start)
        ex3 = bool(e_end > start)
        ex4 = bool(end > e_end)
        ex5 = ex1 and ex2
        ex6 = ex3 and ex4
        ex7 = ex5 or ex6
        if ex7:
            print "conflict"
            result.append(e)
            print "done"
    return result
Beispiel #4
0
def get_related_tags(name):
    if name == None:
        return []
    entries = db((db.tag_assoc.to_ == name) | (db.tag_assoc.from_ == name)).select()
    result = []
    for e in entries:
        print "entry: ", e
        if (name == e.to_):
            other = e.from_
        elif (name == e.from_):
            other = e.to_
        result.append(TagData(other, e.num))
        #imin = 0
        #imax = len(result)
        #while imin < imax:
        #    imid = round((imin + imax) / 2)
        #    if (strength > result[imid].rel_str):
        #        imin = imid + 1
        #    else:
        #        imax = imid
        #result.insert(imin, TagData(name, strength))
    #result.reverse()
    print "result: ", result
    return result
    from pyamf.adapters import _google_appengine_ext_db as adapter_db
    from pyamf.adapters import _google_appengine_ext_blobstore as adapter_blobstore
except ImportError:
    # mock it
    class db(object):
        def __getattr__(self, name):
            class c(object):
                def __init__(self, *args, **kwargs):
                    pass

            return c

        def __nonzero__(self):
            return False

    db = db()


import pyamf
from pyamf import amf3
from pyamf.tests import util

Spam = util.Spam


class PetModel(db.Model):
    """
    """

    # 'borrowed' from http://code.google.com/appengine/docs/datastore/entitiesandmodels.html
    name = db.StringProperty(required=True)
Beispiel #6
0
    from pyamf.adapters import _google_appengine_ext_db as adapter_db
    from pyamf.adapters import _google_appengine_ext_blobstore as adapter_blobstore
except ImportError:
    # mock it
    class db(object):
        def __getattr__(self, name):
            class c(object):
                def __init__(self, *args, **kwargs):
                    pass

            return c

        def __nonzero__(self):
            return False

    db = db()

import pyamf
from pyamf import amf3
from pyamf.tests import util

Spam = util.Spam


class PetModel(db.Model):
    """
    """

    # 'borrowed' from http://code.google.com/appengine/docs/datastore/entitiesandmodels.html
    name = db.StringProperty(required=True)
    type = db.StringProperty(required=True,
Beispiel #7
0
## Here is sample code if you need for
## - email capabilities
## - authentication (registration, login, logout, ... )
## - authorization (role based authorization)
## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
## - old style crud actions
## (more options discussed in gluon/tools.py)
#########################################################################

from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
auth = Auth(db)
crud, service, plugins = Crud(db), Service(), PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)
if (db(db.auth_group.role == 'viewer').isempty()):
    auth.add_group ('viewer')
if (db(db.auth_group.role == 'poster').isempty()):
    auth.add_group ('poster')

## configure email
mail = auth.settings.mailer
mail.settings.server = 'logging' or 'smtp.gmail.com:587'
mail.settings.sender = '*****@*****.**'
mail.settings.login = '******'

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True