コード例 #1
0
ファイル: budg_tables.py プロジェクト: CMcFeaters/budgetMan
'''
budg_tables
this contains all of the setup data for the tables
'''
from appHolder import db
import datetime, inspect, types
import sys, string, os

'''remove these lines when done with debugging
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
path="Users/Charles/Dropbox/Programming/DataBases/budget.db"
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////'+path
db = SQLAlchemy(app)
db.create_all()
'''

def create_a_thing(table,args):
	'''a function that will create a "thing"
	the thing will be an Account, Expense or any other budget related object
	the args will be the parameters required
	assume the user knows what the hell he is doing'''
	thing=table(*args)
	db.session.add(thing)
	db.session.commit()

class dateRange():
	'''an array of all days between two dates'''
	def __init__(self,startDate=datetime.datetime.today(),endDate=datetime.date(datetime.datetime.today().year+1,datetime.datetime.today().month,datetime.datetime.today().day)):
		self.startDate=startDate
コード例 #2
0
ファイル: budg_page.py プロジェクト: CMcFeaters/budgetMan
		expData=acData.expenses
		(tf_in,tf_out)=acData.getTransfers()	#[(tfIn,tfOut)]
		
	#otherwise we return with the option to select the accoutn data
	return render_template('budg_account_data.html',acData=acData,
		ddList=ddList,cfData=cfData,expData=expData,
		tf_in=tf_in, tf_out=tf_out,tDate=datetime.date.today())


#simple python scripts made part of jinja template
@app.template_test('less10')
def less10(value):
	'''takes in a value and dertmines if it is less than 10'''
	return (value<10)
app.jinja_env.tests['less10']=less10

#simple python scripts made part of jinja template
@app.template_filter('url_ext')
def url_ext(*value):
	'''takes in a value and dertmines if it is less than 10'''
	print value
	print type(value)
	for thing in value:
		for stuff in thing:
			print stuff
	return url_for(value[0][0],title=value[0][1])
app.jinja_env.filters['url_ext']=url_ext

if __name__=='__main__':
	db.create_all()
	app.run()