Example #1
0
def my_view(request):
    if 'q' in request.params:
        q = request.params['q']
        pictures = Photo.find_by_tag(q).all()
    else:
        pictures = []
    #return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {
        'pictures': pictures
    }
Example #2
0
def scan_dir(d, tags):
    files = os.listdir(d)

    for f in files:
        path = os.path.join(d, f)
        if f.startswith('.'):
            continue
        if os.path.isdir(path):
            scan_dir(path, tags + [ f ])

        if os.path.splitext(f.lower())[1] not in [ '.jpg', '.jpeg' ]:
            continue

        photo_tags = tags + [ os.path.splitext(f)[0] ]
        p = Photo(path)
        session.add(p)
        try:
            p.set_tags(set(photo_tags))
        except:
            print(photo_tags)
            raise
        session.flush()