global.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. session.forget()
  2. def get(args):
  3. if args[0].startswith('__'):
  4. return None
  5. try:
  6. obj = globals(),get(args[0])
  7. for k in range(1,len(args)):
  8. obj = getattr(obj,args[k])
  9. return obj
  10. except:
  11. return None
  12. def vars():
  13. """the running controller function!"""
  14. title = '.'.join(request.args)
  15. attributes = {}
  16. if not request.args:
  17. (doc,keys,t,c,d,value)=('Global variables',globals(),None,None,[],None)
  18. elif len(request.args) < 3:
  19. obj = get(request.args)
  20. if obj:
  21. doc = getattr(obj,'__doc__','no documentation')
  22. keys = dir(obj)
  23. t = type(obj)
  24. c = getattr(obj,'__class__',None)
  25. d = getattr(obj,'__bases__',None)
  26. for key in keys:
  27. a = getattr(obj,key,None)
  28. if a and not isinstance(a,DAL):
  29. doc1 = getattr(a, '__doc__', '')
  30. t1 = type(a)
  31. c1 = getattr(a,'__class__',None)
  32. d1 = getattr(a,'__bases__',None)
  33. key = '.'.join(request.args)+'.'+key
  34. attributes[key] = (doc1, t1, c1, d1)
  35. else:
  36. doc = 'Unkown'
  37. keys = []
  38. t = c = d = None
  39. else:
  40. raise HTTP(400)
  41. return dict(
  42. title=title,
  43. args=request.args,
  44. t=t,
  45. c=c,
  46. d=d,
  47. doc=doc,
  48. attributes=attributes,
  49. )