cleaned up examples/controller/global.py
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.4.2-stable+timestamp.2013.03.08.19.22.01
|
Version 2.4.2-stable+timestamp.2013.03.09.00.16.49
|
||||||
|
|||||||
@@ -4,72 +4,48 @@ response.menu = [['home', False, '/%s/default/index'
|
|||||||
% request.application], ['docs', True,
|
% request.application], ['docs', True,
|
||||||
'/%s/global/vars' % request.application]]
|
'/%s/global/vars' % request.application]]
|
||||||
|
|
||||||
|
def get(args):
|
||||||
|
try:
|
||||||
|
obj = globals(),get(args[0])
|
||||||
|
for k in range(1,len(args)):
|
||||||
|
obj = getattr(obj,args[k])
|
||||||
|
return obj
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def vars():
|
def vars():
|
||||||
"""the running controller function!"""
|
"""the running controller function!"""
|
||||||
|
title = '.'.join(request.args)
|
||||||
|
attributes = {}
|
||||||
if not request.args:
|
if not request.args:
|
||||||
(
|
(doc,keys,t,c,d,value)=('Global variables',globals(),None,None,[],None)
|
||||||
doc,
|
|
||||||
keys,
|
|
||||||
t,
|
|
||||||
c,
|
|
||||||
d,
|
|
||||||
value,
|
|
||||||
) = (
|
|
||||||
'Global variables',
|
|
||||||
globals(),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
(),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
(title, args) = ('globals()', '')
|
|
||||||
elif len(request.args) < 3:
|
elif len(request.args) < 3:
|
||||||
args = '.'.join(request.args)
|
obj = get(request.args)
|
||||||
try:
|
if obj:
|
||||||
doc = eval(args + '.__doc__')
|
doc = getattr(obj,'__doc__','no documentation')
|
||||||
except:
|
keys = dir(obj)
|
||||||
doc = 'no documentation'
|
t = type(obj)
|
||||||
try:
|
c = getattr(obj,'__class__',None)
|
||||||
keys = eval('dir(%s)' % args)
|
d = getattr(obj,'__bases__',None)
|
||||||
except:
|
|
||||||
|
for key in keys:
|
||||||
|
a = getattr(obj,key,None)
|
||||||
|
if a and not isinstance(a,DAL):
|
||||||
|
doc1 = getattr(a, '__doc__', '')
|
||||||
|
t1 = type(a)
|
||||||
|
c1 = getattr(a,'__class__',None)
|
||||||
|
d1 = getattr(a,'__bases__',None)
|
||||||
|
key = '.'.join(request.args)+'.'+key
|
||||||
|
attributes[key] = (doc1, t1, c1, d1)
|
||||||
|
else:
|
||||||
|
doc = 'Unkown'
|
||||||
keys = []
|
keys = []
|
||||||
t = eval('type(%s)' % args)
|
t = c = d = None
|
||||||
try:
|
|
||||||
c = eval('%s.__class__' % args)
|
|
||||||
except:
|
|
||||||
c = None
|
|
||||||
try:
|
|
||||||
d = eval('%s.__bases__' % args)
|
|
||||||
except:
|
|
||||||
d = None
|
|
||||||
title = args
|
|
||||||
args += '.'
|
|
||||||
else:
|
else:
|
||||||
raise HTTP(400)
|
raise HTTP(400)
|
||||||
attributes = {}
|
|
||||||
for key in keys:
|
|
||||||
a = args + key
|
|
||||||
if eval('isinstance(%s,SQLDB)' % a) or a == 'vars':
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
doc1 = eval(a + '.__doc__')
|
|
||||||
except:
|
|
||||||
doc1 = 'no documentation'
|
|
||||||
t1 = eval('type(%s)' % a)
|
|
||||||
try:
|
|
||||||
c1 = eval('%s.__class__' % a)
|
|
||||||
except:
|
|
||||||
c1 = None
|
|
||||||
try:
|
|
||||||
d1 = eval('%s.__bases__' % a)
|
|
||||||
except:
|
|
||||||
d1 = ()
|
|
||||||
attributes[a] = (doc1, t1, c1, d1)
|
|
||||||
return dict(
|
return dict(
|
||||||
title=title,
|
title=title,
|
||||||
args=args,
|
args=request.args,
|
||||||
t=t,
|
t=t,
|
||||||
c=c,
|
c=c,
|
||||||
d=d,
|
d=d,
|
||||||
|
|||||||
@@ -2,46 +2,53 @@
|
|||||||
{{import cgi}}
|
{{import cgi}}
|
||||||
|
|
||||||
<div class="contentleft">
|
<div class="contentleft">
|
||||||
<h1>{{=T('Docs for')}} {{=title}}</h1>
|
<h1>{{=T('Docs for')}} {{=title}}</h1>
|
||||||
|
|
||||||
<div align="right">
|
<div align="right">
|
||||||
[ <a href="http://docs.python.org/tut/">Python Tutorial</a> ]
|
[ <a href="http://docs.python.org/tut/">Python Tutorial</a> ]
|
||||||
[ <a href="http://docs.python.org/lib/">Python Libraries</a> ]
|
[ <a href="http://docs.python.org/lib/">Python Libraries</a> ]
|
||||||
[ <a href="/{{=request.application}}/static/epydoc/index.html">web2py epydoc</a> ]
|
[ <a href="/{{=request.application}}/static/epydoc/index.html">web2py epydoc</a> ]
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>{{=T('Description')}}</h2>
|
<h2>{{=T('Description')}}</h2>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
{{if t:}}
|
{{if t:}}
|
||||||
{{=t}}{{if d:}} extends {{=d}}{{pass}}
|
{{=t}}{{if d:}} extends {{=d}}{{pass}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
<br/>
|
<br/>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
|
|
||||||
{{if doc:}}<br/><br/>{{=CODE(str(doc),language=None,counter=None,_class='boxCode')}}{{pass}}
|
{{if doc:}}<br/><br/>{{=CODE(str(doc),language=None,counter=None,_class='boxCode')}}{{pass}}
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<div class="boxInfo">
|
<div class="boxInfo">
|
||||||
|
{{if attributes:}}
|
||||||
<h2>{{=T('Attributes')}}</h2>
|
<h2>{{=T('Attributes')}}</h2>
|
||||||
|
|
||||||
{{keys=attributes.keys(); keys.sort()}}
|
|
||||||
<table>
|
<table>
|
||||||
<tr><td colspan=2><hr/></td></tr>
|
<tr><td colspan=2><hr/></td></tr>
|
||||||
{{for a in keys:}}
|
{{for key in sorted(attributes):}}
|
||||||
{{doc1,t1,c1,d1=attributes[a]}}
|
{{doc1,t1,c1,d1=attributes[key]}}
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>{{#=a}}</b>{{=A(a,_href=URL(r=request,args=a.split('.')))}}</td>
|
<td>
|
||||||
<td>
|
{{if key.count('.')<2:}}
|
||||||
{{if t1:}}
|
{{=A(key,_href=URL(args=key.split('.')))}}
|
||||||
{{=t1}}{{if d1:}} extends {{=d1}}{{pass}}
|
{{else:}}
|
||||||
{{if c1:}} belongs to class {{=c1}}{{pass}}
|
{{=key}}
|
||||||
<br/>
|
{{pass}}
|
||||||
{{pass}}
|
</td>
|
||||||
{{if doc1:}}{{=XML(cgi.escape(str(doc1)).replace(chr(13),'<br/>'))}}{{pass}}
|
<td>
|
||||||
|
{{if t1:}}
|
||||||
|
{{=t1}}{{if d1:}} extends {{=d1}}{{pass}}
|
||||||
|
{{if c1:}} belongs to class {{=c1}}{{pass}}
|
||||||
|
<br/>
|
||||||
|
{{pass}}
|
||||||
|
{{if doc1:}}{{=XML(cgi.escape(str(doc1)).replace(chr(13),'<br/>'))}}{{pass}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td colspan=2><hr/></td></tr>
|
<tr><td colspan=2><hr/></td></tr>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{{pass}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user