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


Python AppDashboardData.get_owned_apps方法代码示例

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


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

示例1: test_get_owned_apps

# 需要导入模块: from app_dashboard_data import AppDashboardData [as 别名]
# 或者: from app_dashboard_data.AppDashboardData import get_owned_apps [as 别名]
  def test_get_owned_apps(self):
    # slip in some fake users
    self.setupUserInfoMocks()

    # mock out the App Engine Users API
    self.setupUsersAPIMocks()

    data1 = AppDashboardData()

    # First call, not logged in.
    output = data1.get_owned_apps()
    self.assertEqual(len(output), 0)

    # First user: [email protected], apps=app1,app2
    output = data1.get_owned_apps()
    self.assertTrue('app1' in output)
    self.assertTrue('app2' in output)

    # Second user: [email protected], apps=app2
    output = data1.get_owned_apps()
    self.assertTrue('app2' in output)

    # Third user: [email protected], admin=app2.
    output = data1.get_owned_apps()
    self.assertTrue('app2' in output)
开发者ID:0xmilk,项目名称:appscale,代码行数:27,代码来源:test_app_dashboard_data.py

示例2: AppDashboard

# 需要导入模块: from app_dashboard_data import AppDashboardData [as 别名]
# 或者: from app_dashboard_data.AppDashboardData import get_owned_apps [as 别名]
class AppDashboard(webapp2.RequestHandler):
  """ Class that all pages in the Dashboard must inherit from. """


  # Regular expression to capture the continue url.
  CONTINUE_URL_REGEX = 'continue=(.*)$'


  # Regular expression for updating user permissions.
  USER_PERMISSION_REGEX = '^user_permission_'


  # Regular expression that matches email addresses.
  USER_EMAIL_REGEX = '^\w[^@\s]*@[^@\s]{2,}$'


  # The frequency, in seconds, that defines how often Task Queue tasks are fired
  # to update the Dashboard's Datastore cache.
  REFRESH_WAIT_TIME = 10


  def __init__(self, request, response):
    """ Constructor.
    
    Args:
      request: The webapp2.Request object that contains information about the
        current web request.
      response: The webapp2.Response object that contains the response to be
        sent back to the browser.
    """
    self.initialize(request, response)
    self.helper = AppDashboardHelper()
    self.dstore = AppDashboardData(self.helper)


  def render_template(self, template_file, values=None):
    """ Renders a template file with all variables loaded.

    Args: 
      template_file: A str with the relative path to template file.
      values: A dict with key/value pairs used as variables in the jinja
        template files.
    Returns:
      A str with the rendered template.
    """
    if values is None:
      values = {}

    owned_apps = self.dstore.get_owned_apps()
    self.helper.update_cookie_app_list(owned_apps, self.request, self.response)

    template = jinja_environment.get_template(template_file)
    sub_vars = {
      'logged_in' : self.helper.is_user_logged_in(),
      'user_email' : self.helper.get_user_email(),
      'is_user_cloud_admin' : self.dstore.is_user_cloud_admin(),
      'can_upload_apps' : self.dstore.can_upload_apps(),
      'apps_user_is_admin_on' : owned_apps,
      'flower_url' : self.dstore.get_flower_url(),
    }
    for key in values.keys():
      sub_vars[key] = values[key]
    return template.render(sub_vars)


  def get_shared_navigation(self):
    """ Renders the shared navigation.

    Returns:
      A str with the navigation bar rendered.
    """
    return self.render_template(template_file='shared/navigation.html')

  def render_page(self, page, template_file, values=None ):
    """ Renders a template with the main layout and nav bar. """
    if values is None:
      values = {}
    self.response.headers['Content-Type'] = 'text/html'
    template = jinja_environment.get_template('layouts/main.html')
    self.response.out.write(template.render(
        page_name=page,
        page_body=self.render_template(template_file, values),
        shared_navigation=self.get_shared_navigation()
        ))
开发者ID:UCSB-CS-RACELab,项目名称:eager-appscale,代码行数:86,代码来源:dashboard.py


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