Example #1
0
#You have to install mako
from mako.lookup import TemplateLookup
import fapws._evwsgi as evwsgi
from fapws import base
#you have to install one of my other code: simple sqlite data mapper
from ssdm import ssdm

i = 0

lookup = TemplateLookup(directories=[
    'templates',
],
                        filesystem_checks=True,
                        module_directory='./modules')
#Thanks to assure the database will first be created (create.py)
con = ssdm.connect('database.db')
db = ssdm.scan_db(con)

import time


def commit(v):
    global count
    con.commit()
    time.sleep(0.1)
    #print "commit"


def names(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    name = environ['PATH_INFO']
Example #2
0
# -*- coding: utf-8 -*-
 
from ssdm import ssdm
import sys
import os


dbfile="test.db"

try:
    os.stat(dbfile)
except OSError:
    print """ERROR!!!! \nApparently you have not yet created the "test.db" file. \nPlease check the README"""
    sys.exit(1)

con=ssdm.connect(dbfile)
db=ssdm.scan_db(con)
r=db.track.get({'rowid':1})
print "MULTI PRIMARY KEYs"
print r.items()
print "r.tracknum:",r.tracknum
print "r.trackartist.artistname:", r.trackartist.artistname
print "r.rowid:", r.rowid

print "NEW TRACK"
n = db.track.new()
n.trackartist = "fs"
n.trackname = "All of me"
n.tracknum = 4
n.diskid = 33
res = n.save() 
Example #3
0
# -*- coding: utf-8 -*-
#You have to install mako
from mako.lookup import TemplateLookup
import fapws._evwsgi as evwsgi
from fapws import base
#you have to install one of my other code: simple sqlite data mapper
from ssdm import ssdm

i=0

lookup = TemplateLookup(directories=['../templates',], filesystem_checks=True, module_directory='./modules')
#Thanks to assure the database will first be created (create.py)
con=ssdm.connect('database.db')
db=ssdm.scan_db(con)

evwsgi.start("0.0.0.0", "8080")
evwsgi.set_base_module(base)
    
def names(environ, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    name=environ['PATH_INFO']
    rec=db.names.select("name='%s'" % name)
    template=lookup.get_template('names.html')
    if rec:
        rec=rec[0]
        ndisp=rec.display+1
        rec.set({'display':ndisp})
        rec.save()
        #uncomment the following to force a commit for each request
        #db.names.commit()
        return [template.render(**{"name":rec.name,"text":rec.text,"display":ndisp})]
Example #4
0
# -*- coding: utf-8 -*-
from mako.lookup import TemplateLookup
import fapws._evwsgi as evwsgi
from fapws import base
from ssdm import ssdm
import sys

dbpath='database.db'
ssdm.debug=False

print ssdm.debug

lookup = TemplateLookup(directories=['templates',], filesystem_checks=True, module_directory='./modules')
con=ssdm.connect(dbpath)
db=ssdm.scan_db(con)

evwsgi.start("0.0.0.0", "8080")
evwsgi.set_base_module(base)
   

def commit(param):
   con.commit()
   print "commit"
 
def disppage(environ, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    #print environ
    page=environ['PATH_INFO']
    rec=db.pages.get({'page':page})
    template=lookup.get_template('page.html')
    if rec: