def post():
 tablename = 'cms_post'
 s3db.set_method(module, resourcename, method='discuss', action=discuss)
 def prep(r):
  if r.interactive:
   if (r.method in ('create', 'update')):
    table = r.table
    series = get_vars.get('~.series_id$name', None)
    if series:
     stable = db.cms_series
     row = db((stable.name == series)).select(stable.id, limitby=(0, 1)).first()
     if row:
      field = table.series_id
      field.default = row.id
      field.readable = field.writable = False
    location_id = get_vars.get('(location)', None)
    if location_id:
     field = table.location_id
     field.default = location_id
     field.readable = field.writable = False
    page = get_vars.get('page', None)
    url = get_vars.get('url')
    if page:
     table.name.default = page
     table.name.readable = table.name.writable = False
     _crud = s3.crud_strings[tablename]
     _crud.label_create = T('New Page')
     _crud.title_update = T('Edit Page')
     if (not url):
      url = URL(c='default', f='index', vars={'page': page})
     s3db.configure(tablename, create_next=url, update_next=url)
    _module = get_vars.get('module', None)
    if _module:
     table.avatar.readable = table.avatar.writable = False
     table.location_id.readable = table.location_id.writable = False
     table.date.readable = table.date.writable = False
     table.expired.readable = table.expired.writable = False
     table.body.widget = s3base.s3_richtext_widget
     resource = get_vars.get('resource', None)
     if (resource in ('about', 'contact', 'help', 'index')):
      if (resource == 'about'):
       table.name.default = 'About Page'
      elif (resource == 'contact'):
       table.name.default = 'Contact Page'
      elif (resource == 'help'):
       table.name.default = 'Help Page'
      else:
       table.name.default = 'Home Page'
      table.replies.readable = table.replies.writable = False
      if (not url):
       url = URL(c=_module, f=resource)
     else:
      record = get_vars.get('record', None)
      if record:
       table.name.default = ('%s %s Profile Page' % (resource, record))
       table.title.readable = table.title.writable = False
       table.replies.readable = table.replies.writable = False
       if (not url):
        url = URL(c=_module, f=resource, args=[record, 'profile'])
      elif resource:
       table.name.default = ('%s Summary Page Header' % resource)
       table.title.readable = table.title.writable = False
       table.replies.readable = table.replies.writable = False
       if (not url):
        url = URL(c=_module, f=resource, args='summary')
      else:
       table.name.default = ('%s Home Page' % _module)
       _crud = s3.crud_strings[tablename]
       _crud.label_create = T('New Page')
       _crud.title_update = T('Edit Page')
       if (not url):
        url = URL(c=_module, f='index')
     s3db.configure(tablename, create_next=url, update_next=url)
    layer_id = get_vars.get('layer_id', None)
    if layer_id:
     table.name.default = ('Metadata Page for Layer %s' % layer_id)
     table.name.readable = table.name.writable = False
     table.avatar.readable = table.avatar.writable = False
     table.location_id.readable = table.location_id.writable = False
     table.title.readable = table.title.writable = False
     table.replies.readable = table.replies.writable = False
     table.date.readable = table.date.writable = False
     table.expired.readable = table.expired.writable = False
     _crud = s3.crud_strings[tablename]
     _crud.label_create = T('Add Metadata')
     _crud.title_update = T('Edit Metadata')
    if (r.component_name == 'module'):
     modules = {}
     _modules = current.deployment_settings.modules
     for module in _modules:
      if (module in ('appadmin', 'errors', 'ocr')):
       continue
      modules[module] = _modules[module].name_nice
     s3db.cms_post_module.field.requires = IS_IN_SET_LAZY((lambda : sort_dict_by_values(modules)))
  return True
 s3.prep = prep
 output = s3_rest_controller(rheader=s3db.cms_rheader)
 return output

def post ( ) : tablename = 'cms_post' s3db . set_method ( module , resourcename , method = 'discuss' , action = discuss ) def prep ( r ) : if r . interactive : if ( r . method in ( 'create' , 'update' ) ) : table = r . table series = get_vars . get ( '~.series_id$name' , None ) if series : stable = db . cms_series row = db ( ( stable . name == series ) ) . select ( stable . id , limitby = ( 0 , 1 ) ) . first ( ) if row : field = table . series_id field . default = row . id field . readable = field . writable = False location_id = get_vars . get ( '(location)' , None ) if location_id : field = table . location_id field . default = location_id field . readable = field . writable = False page = get_vars . get ( 'page' , None ) url = get_vars . get ( 'url' ) if page : table . name . default = page table . name . readable = table . name . writable = False _crud = s3 . crud_strings [ tablename ] _crud . label_create = T ( 'New Page' ) _crud . title_update = T ( 'Edit Page' ) if ( not url ) : url = URL ( c = 'default' , f = 'index' , vars = { 'page' : page } ) s3db . configure ( tablename , create_next = url , update_next = url ) _module = get_vars . get ( 'module' , None ) if _module : table . avatar . readable = table . avatar . writable = False table . location_id . readable = table . location_id . writable = False table . date . readable = table . date . writable = False table . expired . readable = table . expired . writable = False table . body . widget = s3base . s3_richtext_widget resource = get_vars . get ( 'resource' , None ) if ( resource in ( 'about' , 'contact' , 'help' , 'index' ) ) : if ( resource == 'about' ) : table . name . default = 'About Page' elif ( resource == 'contact' ) : table . name . default = 'Contact Page' elif ( resource == 'help' ) : table . name . default = 'Help Page' else : table . name . default = 'Home Page' table . replies . readable = table . replies . writable = False if ( not url ) : url = URL ( c = _module , f = resource ) else : record = get_vars . get ( 'record' , None ) if record : table . name . default = ( '%s %s Profile Page' % ( resource , record ) ) table . title . readable = table . title . writable = False table . replies . readable = table . replies . writable = False if ( not url ) : url = URL ( c = _module , f = resource , args = [ record , 'profile' ] ) elif resource : table . name . default = ( '%s Summary Page Header' % resource ) table . title . readable = table . title . writable = False table . replies . readable = table . replies . writable = False if ( not url ) : url = URL ( c = _module , f = resource , args = 'summary' ) else : table . name . default = ( '%s Home Page' % _module ) _crud = s3 . crud_strings [ tablename ] _crud . label_create = T ( 'New Page' ) _crud . title_update = T ( 'Edit Page' ) if ( not url ) : url = URL ( c = _module , f = 'index' ) s3db . configure ( tablename , create_next = url , update_next = url ) layer_id = get_vars . get ( 'layer_id' , None ) if layer_id : table . name . default = ( 'Metadata Page for Layer %s' % layer_id ) table . name . readable = table . name . writable = False table . avatar . readable = table . avatar . writable = False table . location_id . readable = table . location_id . writable = False table . title . readable = table . title . writable = False table . replies . readable = table . replies . writable = False table . date . readable = table . date . writable = False table . expired . readable = table . expired . writable = False _crud = s3 . crud_strings [ tablename ] _crud . label_create = T ( 'Add Metadata' ) _crud . title_update = T ( 'Edit Metadata' ) if ( r . component_name == 'module' ) : modules = { } _modules = current . deployment_settings . modules for module in _modules : if ( module in ( 'appadmin' , 'errors' , 'ocr' ) ) : continue modules [ module ] = _modules [ module ] . name_nice s3db . cms_post_module . field . requires = IS_IN_SET_LAZY ( ( lambda : sort_dict_by_values ( modules ) ) ) return True s3 . prep = prep output = s3_rest_controller ( rheader = s3db . cms_rheader ) return output
execute an http post query .