Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 9d1c398d3ba7de2384fd63a5112a2732bb317fba Jon Romero committed Jan 6, 2010
Showing with 3,187 additions and 0 deletions.
  1. +2 −0 ABOUT
  2. +2 −0 LICENSE
  3. 0 README
  4. 0 __init__.py
  5. BIN __init__.pyc
  6. 0 cache/cache.lock
  7. +253 −0 controllers/appadmin.py
  8. +51 −0 controllers/default.py
  9. +1 −0 cron/crontab
  10. +26 −0 databases/c8b669d15150d7109e5f7ab36744a5b7_auth_event.table
  11. +14 −0 databases/c8b669d15150d7109e5f7ab36744a5b7_auth_group.table
  12. +14 −0 databases/c8b669d15150d7109e5f7ab36744a5b7_auth_membership.table
  13. +22 −0 databases/c8b669d15150d7109e5f7ab36744a5b7_auth_permission.table
  14. +26 −0 databases/c8b669d15150d7109e5f7ab36744a5b7_auth_user.table
  15. +43 −0 databases/sql.log
  16. BIN databases/storage.sqlite
  17. +52 −0 languages/fr-fr.py
  18. +52 −0 languages/it-it.py
  19. +52 −0 languages/it.py
  20. +58 −0 languages/pl-pl.py
  21. +59 −0 languages/pl.py
  22. +55 −0 languages/pt-br.py
  23. +53 −0 languages/pt-pt.py
  24. +53 −0 languages/pt.py
  25. +64 −0 languages/ru-ru.py
  26. +62 −0 models/db.py
  27. +80 −0 models/menu.py
  28. 0 modules/__init__.py
  29. BIN modules/__init__.pyc
  30. +1,079 −0 modules/facebook.py
  31. BIN modules/facebook.pyc
  32. +4 −0 sessions/127-0-0-1-511e3e3e-5db0-43ee-8fe8-9302059c48a6
  33. +603 −0 static/base.css
  34. +1 −0 static/calendar.css
  35. +80 −0 static/calendar.js
  36. +19 −0 static/jquery.js
  37. BIN static/title.png
  38. +6 −0 static/xd_receiver.htm
  39. +80 −0 views/appadmin.html
  40. +43 −0 views/default/index.html
  41. +7 −0 views/default/user.html
  42. +18 −0 views/generic.html
  43. +11 −0 views/generic.json
  44. +16 −0 views/generic.rss
  45. +11 −0 views/generic.xml
  46. +71 −0 views/layout.html
  47. +44 −0 views/web2py_ajax.html
2 ABOUT
@@ -0,0 +1,2 @@
+Write something about this app.
+Developed with web2py.
@@ -0,0 +1,2 @@
+This is a sample license. You can write here anything you want
+as long as you do not violate web2py copyright, trademark and license.
0 README
No changes.
No changes.
Binary file not shown.
No changes.
@@ -0,0 +1,253 @@
+# coding: utf8
+
+# ##########################################################
+# ## make sure administrator is on localhost
+# ###########################################################
+
+import os
+import socket
+import datetime
+import copy
+import gluon.contenttype
+import gluon.fileutils
+
+# ## crytical --- make a copy of the environment
+
+global_env = copy.copy(globals())
+global_env['datetime'] = datetime
+
+http_host = request.env.http_host.split(':')[0]
+remote_addr = request.env.remote_addr
+try:
+ hosts = (http_host, socket.gethostbyname(remote_addr))
+except:
+ hosts = (http_host, )
+if remote_addr not in hosts:
+ raise HTTP(400)
+if not gluon.fileutils.check_credentials(request):
+ redirect('/admin')
+
+ignore_rw = True
+response.view = 'appadmin.html'
+response.menu = [[T('design'), False, URL('admin', 'default', 'design',
+ args=[request.application])], [T('db'), False,
+ URL(r=request, f='index')], [T('state'), False,
+ URL(r=request, f='state')]]
+
+# ##########################################################
+# ## auxiliary functions
+# ###########################################################
+
+
+def get_databases(request):
+ dbs = {}
+ for (key, value) in global_env.items():
+ cond = False
+ try:
+ cond = isinstance(value, GQLDB)
+ except:
+ cond = isinstance(value, SQLDB)
+ if cond:
+ dbs[key] = value
+ return dbs
+
+
+databases = get_databases(None)
+
+
+def eval_in_global_env(text):
+ exec ('_ret=%s' % text, {}, global_env)
+ return global_env['_ret']
+
+
+def get_database(request):
+ if request.args and request.args[0] in databases:
+ return eval_in_global_env(request.args[0])
+ else:
+ session.flash = T('invalid request')
+ redirect(URL(r=request, f='index'))
+
+
+def get_table(request):
+ db = get_database(request)
+ if len(request.args) > 1 and request.args[1] in db.tables:
+ return (db, request.args[1])
+ else:
+ session.flash = T('invalid request')
+ redirect(URL(r=request, f='index'))
+
+
+def get_query(request):
+ try:
+ return eval_in_global_env(request.vars.query)
+ except Exception:
+ return None
+
+
+# ##########################################################
+# ## list all databases and tables
+# ###########################################################
+
+
+def index():
+ return dict(databases=databases)
+
+
+# ##########################################################
+# ## insert a new record
+# ###########################################################
+
+
+def insert():
+ (db, table) = get_table(request)
+ form = SQLFORM(db[table], ignore_rw=ignore_rw)
+ if form.accepts(request.vars, session):
+ response.flash = T('new record inserted')
+ return dict(form=form)
+
+
+# ##########################################################
+# ## list all records in table and insert new record
+# ###########################################################
+
+
+def download():
+ import os
+ db = get_database(request)
+ return response.download(request,db)
+
+def csv():
+ import gluon.contenttype
+ response.headers['Content-Type'] = \
+ gluon.contenttype.contenttype('.csv')
+ db = get_database(request)
+ query = get_query(request)
+ if not query:
+ return None
+ response.headers['Content-disposition'] = 'attachment; filename=%s_%s.csv'\
+ % tuple(request.vars.query.split('.')[:2])
+ return str(db(query).select())
+
+
+def import_csv(table, file):
+ table.import_from_csv_file(file)
+
+def select():
+ import re
+ db = get_database(request)
+ dbname = request.args[0]
+ regex = re.compile('(?P<table>\w+)\.(?P<field>\w+)=(?P<value>\d+)')
+ if request.vars.query:
+ match = regex.match(request.vars.query)
+ if match:
+ request.vars.query = '%s.%s.%s==%s' % (request.args[0],
+ match.group('table'), match.group('field'),
+ match.group('value'))
+ else:
+ request.vars.query = session.last_query
+ query = get_query(request)
+ if request.vars.start:
+ start = int(request.vars.start)
+ else:
+ start = 0
+ nrows = 0
+ stop = start + 100
+ table = None
+ rows = []
+ orderby = request.vars.orderby
+ if orderby:
+ orderby = dbname + '.' + orderby
+ if orderby == session.last_orderby:
+ if orderby[0] == '~':
+ orderby = orderby[1:]
+ else:
+ orderby = '~' + orderby
+ session.last_orderby = orderby
+ session.last_query = request.vars.query
+ form = FORM(TABLE(TR(T('Query:'), '', INPUT(_style='width:400px',
+ _name='query', _value=request.vars.query or '',
+ requires=IS_NOT_EMPTY(error_message=T("Cannot be empty")))), TR(T('Update:'),
+ INPUT(_name='update_check', _type='checkbox',
+ value=False), INPUT(_style='width:400px',
+ _name='update_fields', _value=request.vars.update_fields
+ or '')), TR(T('Delete:'), INPUT(_name='delete_check',
+ _class='delete', _type='checkbox', value=False), ''),
+ TR('', '', INPUT(_type='submit', _value='submit'))),
+ _action=URL(r=request,args=request.args))
+ if request.vars.csvfile != None:
+ try:
+ import_csv(db[request.vars.table],
+ request.vars.csvfile.file)
+ response.flash = T('data uploaded')
+ except:
+ response.flash = T('unable to parse csv file')
+ if form.accepts(request.vars, formname=None):
+ regex = re.compile(request.args[0] + '\.(?P<table>\w+)\.id\>0')
+ match = regex.match(form.vars.query.strip())
+ if match:
+ table = match.group('table')
+ try:
+ nrows = db(query).count()
+ if form.vars.update_check and form.vars.update_fields:
+ db(query).update(**eval_in_global_env('dict(%s)'
+ % form.vars.update_fields))
+ response.flash = T('%s rows updated', nrows)
+ elif form.vars.delete_check:
+ db(query).delete()
+ response.flash = T('%s rows deleted', nrows)
+ nrows = db(query).count()
+ if orderby:
+ rows = db(query).select(limitby=(start, stop),
+ orderby=eval_in_global_env(orderby))
+ else:
+ rows = db(query).select(limitby=(start, stop))
+ except:
+ (rows, nrows) = ([], 0)
+ response.flash = T('Invalid Query')
+ return dict(
+ form=form,
+ table=table,
+ start=start,
+ stop=stop,
+ nrows=nrows,
+ rows=rows,
+ query=request.vars.query,
+ )
+
+
+# ##########################################################
+# ## edit delete one record
+# ###########################################################
+
+
+def update():
+ (db, table) = get_table(request)
+ try:
+ id = int(request.args[2])
+ record = db(db[table].id == id).select()[0]
+ except:
+ session.flash = T('record does not exist')
+ redirect(URL(r=request, f='select', args=request.args[:1],
+ vars=dict(query='%s.%s.id>0'
+ % tuple(request.args[:2]))))
+ form = SQLFORM(db[table], record, deletable=True, delete_label=T('Check to delete'), ignore_rw=ignore_rw,
+ linkto=URL(r=request, f='select',
+ args=request.args[:1]), upload=URL(r=request,
+ f='download', args=request.args[:1]))
+ if form.accepts(request.vars, session):
+ response.flash = T('done!')
+ redirect(URL(r=request, f='select', args=request.args[:1],
+ vars=dict(query='%s.%s.id>0'
+ % tuple(request.args[:2]))))
+ return dict(form=form)
+
+
+# ##########################################################
+# ## get global variables
+# ###########################################################
+
+
+def state():
+ return dict()
+
+
@@ -0,0 +1,51 @@
+# coding: utf8
+from applications.fbconnect.modules.facebook import *
+
+facebook_settings.FACEBOOK_API_KEY = 'xxx'
+facebook_settings.FACEBOOK_SECRET_KEY = 'xxx'
+facebook_settings.FACEBOOK_APP_NAME = "fbconnect-web2py"
+facebook_settings.FACEBOOK_INTERNAL = True
+facebook_settings.FACEBOOK_CALLBACK_PATH = "/fbconnect/default/test"
+
+def index():
+ connected = facebook_connect(request, facebook_settings)
+ if connected:
+ user = get_facebook_user(request.facebook)
+ response.flash = "Hello ", user
+
+ return dict(api_key=facebook_settings.FACEBOOK_API_KEY)
+
+
+def user():
+ """
+ exposes:
+ http://..../[app]/default/user/login
+ http://..../[app]/default/user/logout
+ http://..../[app]/default/user/register
+ http://..../[app]/default/user/profile
+ http://..../[app]/default/user/retrieve_password
+ http://..../[app]/default/user/change_password
+ use @auth.requires_login()
+ @auth.requires_membership('group name')
+ @auth.requires_permission('read','table name',record_id)
+ to decorate functions that need access control
+ """
+ return dict(form=auth())
+
+
+def download():
+ """
+ allows downloading of uploaded files
+ http://..../[app]/default/download/[filename]
+ """
+ return response.download(request,db)
+
+
+def call():
+ """
+ exposes services. for example:
+ http://..../[app]/default/call/jsonrpc
+ decorate with @services.jsonrpc the functions to expose
+ supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
+ """
+ return service()
@@ -0,0 +1 @@
+#crontab
@@ -0,0 +1,26 @@
+(dp1
+S'origin'
+p2
+S'CHAR(32)'
+p3
+sS'client_ip'
+p4
+S'CHAR(32)'
+p5
+sS'user_id'
+p6
+S'REFERENCES auth_user(id) ON DELETE CASCADE'
+p7
+sS'description'
+p8
+S'TEXT'
+p9
+sS'time_stamp'
+p10
+S'TIMESTAMP'
+p11
+sS'id'
+p12
+S'INTEGER PRIMARY KEY AUTOINCREMENT'
+p13
+s.
@@ -0,0 +1,14 @@
+(dp1
+S'role'
+p2
+S'CHAR(128)'
+p3
+sS'id'
+p4
+S'INTEGER PRIMARY KEY AUTOINCREMENT'
+p5
+sS'description'
+p6
+S'TEXT'
+p7
+s.
@@ -0,0 +1,14 @@
+(dp1
+S'group_id'
+p2
+S'REFERENCES auth_group(id) ON DELETE CASCADE'
+p3
+sS'user_id'
+p4
+S'REFERENCES auth_user(id) ON DELETE CASCADE'
+p5
+sS'id'
+p6
+S'INTEGER PRIMARY KEY AUTOINCREMENT'
+p7
+s.
@@ -0,0 +1,22 @@
+(dp1
+S'record_id'
+p2
+S'INTEGER'
+p3
+sS'group_id'
+p4
+S'REFERENCES auth_group(id) ON DELETE CASCADE'
+p5
+sS'table_name'
+p6
+S'CHAR(32)'
+p7
+sS'id'
+p8
+S'INTEGER PRIMARY KEY AUTOINCREMENT'
+p9
+sS'name'
+p10
+S'CHAR(32)'
+p11
+s.
Oops, something went wrong.

0 comments on commit 9d1c398

Please sign in to comment.