當前位置: 首頁>>代碼示例>>Python>>正文


Python App.orderable_app_ids方法代碼示例

本文整理匯總了Python中rogerthat.models.App.orderable_app_ids方法的典型用法代碼示例。如果您正苦於以下問題:Python App.orderable_app_ids方法的具體用法?Python App.orderable_app_ids怎麽用?Python App.orderable_app_ids使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rogerthat.models.App的用法示例。


在下文中一共展示了App.orderable_app_ids方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import orderable_app_ids [as 別名]

#.........這裏部分代碼省略.........
        elif not dashboard_email_address:
            result = "Failed to create new app (dashboard_email_address was empty)!"
        else:
            try:
                if user_regex:
                    validate_user_regex(user_regex)

                zip_stream = self.request.POST.get('core_branding').file
                zip_stream.seek(0)
                try:
                    zip_ = ZipFile(zip_stream)
                except BadZipfile, e:
                    raise BrandingValidationException(e.message)

                branding = store_branding_zip(None, zip_, u"Core branding of %s" % app_id)

                app = App(key=App.create_key(app_id))
                to_be_put = []
                app.qrtemplate_keys = []
                for i in xrange(qr_templates_count):
                    file_ = self.request.POST.get('qr_template_%s' % i)
                    description = self.request.POST.get("qr_template_description_%s" % i)
                    color = self.request.POST.get("qr_template_color_%s" % i)
                    file_ = file_.file.getvalue() if isinstance(file_, FieldStorage) else None
                    key_name = create_qr_template_key_name(app_id, description)
                    store_template(None, file_, description, color, key_name)
                    if default_qr_template_index == i:
                        app.qrtemplate_keys.insert(0, key_name)
                    else:
                        app.qrtemplate_keys.append(key_name)

                app.name = name
                app.type = app_type
                app.core_branding_hash = branding.hash
                app.facebook_app_id = fb_app_id
                app.ios_app_id = ios_app_id
                app.android_app_id = android_app_id
                app.dashboard_email_address = dashboard_email_address
                app.contact_email_address = contact_email_address
                app.user_regex = user_regex
                app.creation_time = now()
                app.is_default = get_default_app_key() is None
                app.demo = demo
                app.beta = beta
                app.mdp_client_id = mdp_client_id or None
                app.mdp_client_secret = mdp_client_secret or None

                app.auto_connected_services = AutoConnectedServices()
                for acs in auto_connected_services:
                    service_identity_user = add_slash_default(users.User(acs.service_identity_email))
                    si = get_service_identity(service_identity_user)
                    bizz_check(si, "ServiceIdentity %s not found" % service_identity_user)
                    if app_id not in si.appIds:
                        si.appIds.append(app_id)
                        to_be_put.append(si)

                    acs.service_identity_email = service_identity_user.email()
                    app.auto_connected_services.add(acs)

                admin_profiles = db.get([get_profile_key(u) for u in map(users.User, admin_services)])
                non_existing = list()
                for admin_email, admin_profile in zip(admin_services, admin_profiles):
                    if not admin_profile:
                        non_existing.append(admin_email)
                bizz_check(not non_existing, "Non existing services specified: %s" % non_existing)
                app.admin_services = admin_services
                app.beacon_major = beacon_major
                app.beacon_last_minor = 0
                put_and_invalidate_cache(*to_be_put)

                to_be_put = []
                for beacon_region in beacon_regions:
                    uuid = beacon_region.get("uuid")
                    major = beacon_region.get("major")
                    minor = beacon_region.get("minor")
                    br = BeaconRegion(key=BeaconRegion.create_key(app.key(), uuid, major, minor))
                    br.uuid = uuid.lower()
                    br.major = major
                    br.minor = minor
                    br.creation_time = now()
                    to_be_put.append(br)

                app.orderable_app_ids = list(orderable_apps)
                apps = db.get(map(App.create_key, app.orderable_app_ids))
                for a in apps:
                    a.orderable_app_ids.append(app_id)
                    to_be_put.append(a)
                to_be_put.append(app)
                put_and_invalidate_cache(*to_be_put)

                for acs in app.auto_connected_services:
                    logging.info("There is a new auto-connected service: %s", acs.service_identity_email)
                    run_job(get_user_profile_keys_by_app_id, [app_id],
                            hookup_with_default_services.run_for_auto_connected_service, [acs, None])

                result = "Created new app!"
                success = True
            except BusinessException, e:
                logging.info("BusinessException: %s", e, exc_info=1)
                result = e.message
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:104,代碼來源:apps.py


注:本文中的rogerthat.models.App.orderable_app_ids方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。