minor changes to welcome3
This commit is contained in:
@@ -89,10 +89,8 @@ def get_databases(request):
|
||||
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']
|
||||
@@ -105,7 +103,6 @@ def get_database(request):
|
||||
session.flash = T('invalid request')
|
||||
redirect(URL('index'))
|
||||
|
||||
|
||||
def get_table(request):
|
||||
db = get_database(request)
|
||||
if len(request.args) > 1 and request.args[1] in db.tables:
|
||||
@@ -464,34 +461,24 @@ def ccache():
|
||||
if value[0] < ram['oldest']:
|
||||
ram['oldest'] = value[0]
|
||||
ram['keys'].append((key, GetInHMS(time.time() - value[0])))
|
||||
folder = os.path.join(request.folder,'cache')
|
||||
if not os.path.exists(folder):
|
||||
os.mkdir(folder)
|
||||
locker = open(os.path.join(folder, 'cache.lock'), 'a')
|
||||
portalocker.lock(locker, portalocker.LOCK_EX)
|
||||
disk_storage = shelve.open(
|
||||
os.path.join(folder, 'cache.shelve'))
|
||||
try:
|
||||
for key, value in disk_storage.items():
|
||||
if isinstance(value, dict):
|
||||
disk['hits'] = value['hit_total'] - value['misses']
|
||||
disk['misses'] = value['misses']
|
||||
try:
|
||||
disk['ratio'] = disk['hits'] * 100 / value['hit_total']
|
||||
except (KeyError, ZeroDivisionError):
|
||||
disk['ratio'] = 0
|
||||
else:
|
||||
if hp:
|
||||
disk['bytes'] += hp.iso(value[1]).size
|
||||
disk['objects'] += hp.iso(value[1]).count
|
||||
disk['entries'] += 1
|
||||
if value[0] < disk['oldest']:
|
||||
disk['oldest'] = value[0]
|
||||
disk['keys'].append((key, GetInHMS(time.time() - value[0])))
|
||||
finally:
|
||||
portalocker.unlock(locker)
|
||||
locker.close()
|
||||
disk_storage.close()
|
||||
|
||||
for key in cache.disk.storage:
|
||||
value = cache.disk.storage[key]
|
||||
if isinstance(value, dict):
|
||||
disk['hits'] = value['hit_total'] - value['misses']
|
||||
disk['misses'] = value['misses']
|
||||
try:
|
||||
disk['ratio'] = disk['hits'] * 100 / value['hit_total']
|
||||
except (KeyError, ZeroDivisionError):
|
||||
disk['ratio'] = 0
|
||||
else:
|
||||
if hp:
|
||||
disk['bytes'] += hp.iso(value[1]).size
|
||||
disk['objects'] += hp.iso(value[1]).count
|
||||
disk['entries'] += 1
|
||||
if value[0] < disk['oldest']:
|
||||
disk['oldest'] = value[0]
|
||||
disk['keys'].append((key, GetInHMS(time.time() - value[0])))
|
||||
|
||||
total['entries'] = ram['entries'] + disk['entries']
|
||||
total['bytes'] = ram['bytes'] + disk['bytes']
|
||||
@@ -585,7 +572,7 @@ def bg_graph_model():
|
||||
if hasattr(db[tablename],'_meta_graphmodel'):
|
||||
meta_graphmodel = db[tablename]._meta_graphmodel
|
||||
else:
|
||||
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
|
||||
meta_graphmodel = dict(group=request.application, color='#ECECEC')
|
||||
|
||||
group = meta_graphmodel['group'].replace(' ', '')
|
||||
if not subgraphs.has_key(group):
|
||||
@@ -670,3 +657,46 @@ def manage():
|
||||
kwargs.update(**smartgrid_args.get(table._tablename, {}))
|
||||
grid = SQLFORM.smartgrid(table, args=request.args[:2], formname=formname, **kwargs)
|
||||
return grid
|
||||
|
||||
def hooks():
|
||||
import functools
|
||||
import inspect
|
||||
list_op=['_%s_%s' %(h,m) for h in ['before', 'after'] for m in ['insert','update','delete']]
|
||||
tables=[]
|
||||
with_build_it=False
|
||||
for db_str in sorted(databases):
|
||||
db = databases[db_str]
|
||||
for t in db.tables:
|
||||
method_hooks=[]
|
||||
for op in list_op:
|
||||
functions = []
|
||||
for f in getattr(db[t], op):
|
||||
if hasattr(f, '__call__'):
|
||||
try:
|
||||
if isinstance(f, (functools.partial)):
|
||||
f = f.func
|
||||
filename = inspect.getsourcefile(f)
|
||||
details = {'funcname':f.__name__,
|
||||
'filename':filename[len(request.folder):] if request.folder in filename else None,
|
||||
'lineno': inspect.getsourcelines(f)[1]}
|
||||
if details['filename']: # Built in functions as delete_uploaded_files are not editable
|
||||
details['url'] = URL(a='admin',c='default',f='edit', args=[request['application'], details['filename']],vars={'lineno':details['lineno']})
|
||||
if details['filename'] or with_build_it:
|
||||
functions.append(details)
|
||||
# compiled app and windows build don't support code inspection
|
||||
except:
|
||||
pass
|
||||
if len(functions):
|
||||
method_hooks.append({'name':op, 'functions':functions})
|
||||
if len(method_hooks):
|
||||
tables.append({'name':"%s.%s" % (db_str,t), 'slug': IS_SLUG()("%s.%s" % (db_str,t))[0], 'method_hooks':method_hooks})
|
||||
# Render
|
||||
ul_main = UL(_class='nav nav-list')
|
||||
for t in tables:
|
||||
ul_main.append(A(t['name'], _onclick="collapse('a_%s')" % t['slug']))
|
||||
ul_t = UL(_class='nav nav-list', _id="a_%s" % t['slug'], _style='display:none')
|
||||
for op in t['method_hooks']:
|
||||
ul_t.append(LI (op['name']))
|
||||
ul_t.append(UL([LI(A(f['funcname'], _class="editor_filelink", _href=f['url']if 'url' in f else None, **{'_data-lineno':f['lineno']-1})) for f in op['functions']]))
|
||||
ul_main.append(ul_t)
|
||||
return ul_main
|
||||
|
||||
@@ -6,14 +6,12 @@
|
||||
#########################################################################
|
||||
|
||||
response.logo = A(B('web',SPAN(2),'py'),XML('™ '),
|
||||
_class="navbar-brand",_href="http://www.web2py.com/",
|
||||
_id="web2py-logo")
|
||||
_class="brand",_href="http://www.web2py.com/")
|
||||
response.title = request.application.replace('_',' ').title()
|
||||
response.subtitle = ''
|
||||
|
||||
## read more at http://dev.w3.org/html5/markup/meta.name.html
|
||||
response.meta.author = 'Your Name <you@example.com>'
|
||||
response.meta.description = 'a cool new app'
|
||||
response.meta.keywords = 'web2py, python, framework'
|
||||
response.meta.generator = 'Web2py Web Framework'
|
||||
|
||||
@@ -126,7 +124,15 @@ def _():
|
||||
(T('Live Chat'), False,
|
||||
'http://webchat.freenode.net/?channels=web2py'),
|
||||
]),
|
||||
(T('Plugins'), False, 'http://web2py.com/plugins')]
|
||||
(T('Plugins'), False, None, [
|
||||
('plugin_wiki', False,
|
||||
'http://web2py.com/examples/default/download'),
|
||||
(T('Other Plugins'), False,
|
||||
'http://web2py.com/plugins'),
|
||||
(T('Layout Plugins'),
|
||||
False, 'http://web2py.com/layouts'),
|
||||
])
|
||||
]
|
||||
)]
|
||||
if DEVELOPMENT_MENU: _()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user