当前位置: 首页>>代码示例>>Python>>正文


Python Constants.gm_arg_decode方法代码示例

本文整理汇总了Python中Constants.gm_arg_decode方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.gm_arg_decode方法的具体用法?Python Constants.gm_arg_decode怎么用?Python Constants.gm_arg_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Constants的用法示例。


在下文中一共展示了Constants.gm_arg_decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_actions

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import gm_arg_decode [as 别名]
def process_actions(request):
  '''Processes all actions in a request'''
  rootid = request.getvalue('global_rootid', '')
  for action in request.getlist('gm_action'):
    # decode the action -- this uses reflection to call the appropriate action
    try:
      view, funcname = action.split('.')[:2]
    except ValueError: # no period was sent in
      view = request.getvalue('global_view', '')
      funcname = action

    # get a ref to the module and func desired
    try:
      func = getattr(BaseView.views[view.lower()], funcname + '_action')  # I add _action for security reasons.  It ensures that no method except one ending with _action can ever be called from a browser form.
    except KeyError:
      Constants.log.warning('Action error: View (' + str(view) + ') in "' + str(action) + '" not found.  Action aborted.')
      continue
      
    # unwrap the arguments to the function
    args = [ request ]
    i = 1
    while True:
      arg = request.getvalue('gm_arg' + str(i))
      if arg == None:
        break
      args.append(Constants.gm_arg_decode(arg)) # javascript in BaseView explicitly encodes arguments since they have to go into a URL, even for post (that's AJAX rules)
      i += 1
      
    # let the function do its work
    # the function should return a single Event object or a list of Event objects
    events = apply(func, args)

    # send the javascript to windows interested in this rootid
    if events:
      if isinstance(events, Event):
        send_event(rootid, events)
      else:
        for event in events:
          send_event(rootid, event)  
开发者ID:ssaltzman,项目名称:POET,代码行数:41,代码来源:Events.py


注:本文中的Constants.gm_arg_decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。