Advertisement
Guest User

getPage()

a guest
Oct 28th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. def getpage():
  2.     """
  3.        Load the page from `webnotes.form` and send it via `webnotes.response`
  4.     """
  5.     page = webnotes.form_dict.get('name')
  6.     doclist = get(page)
  7.    
  8.     if has_permission(doclist):
  9.         # load translations
  10.         if webnotes.lang != "en":
  11.             from webnotes.modules import get_doc_path
  12.             from webnotes.translate import get_lang_data
  13.             d = doclist[0]
  14.             messages_js = get_lang_data(get_doc_path(d.module, d.doctype, d.name),
  15.                 webnotes.lang, 'js')
  16.             messages_py = get_lang_data(get_doc_path(d.module, d.doctype, d.name),
  17.                 webnotes.lang, 'py')
  18.             messages = dict(messages_js,**messages_py)
  19.             webnotes.response["__messages"] = messages
  20.                
  21.         webnotes.response['docs'] = doclist
  22.     else:
  23.         webnotes.response['403'] = 1
  24.         raise webnotes.PermissionError, 'No read permission for Page %s' % \
  25.             (doclist[0].title or page, )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement