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


Python App.create_key方法代碼示例

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


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

示例1: get

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
    def get(self):
        url_app_id = self.request.get('id')
        if url_app_id:
            app = get_app_by_id(url_app_id)
            if app:
                self.write_app_details(app)
                return

        url_new_app = self.request.get('new_app')
        if url_new_app:
            self.write_app_details(None)
            return

        rogerthat_app = get_app_by_id(App.APP_ID_ROGERTHAT)
        if rogerthat_app is None:
            rogerthat_app = App(key=App.create_key(App.APP_ID_ROGERTHAT))
            rogerthat_app.name = "Rogerthat"
            rogerthat_app.type = App.APP_TYPE_ROGERTHAT
            rogerthat_app.creation_time = now()
            rogerthat_app.visible = False
            rogerthat_app.put()

        template = JINJA_ENVIRONMENT.get_template('apps.html')
        context = self.get_request_params()
        context['apps'] = sorted(get_visible_apps(), key=lambda app: (app.is_default, app.name))
        self.response.out.write(template.render(context))
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:28,代碼來源:apps.py

示例2: validate_delete_service

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def validate_delete_service(service_user):
    # type: (users.User) -> None
    all_app_ids = set()
    for service_identity in get_service_identities(service_user):
        all_app_ids.update(service_identity.appIds)
    apps = get_apps_by_keys([App.create_key(app_id) for app_id in all_app_ids])
    for app in apps:
        if app.main_service == service_user.email():
            raise BusinessException('Cannot delete main service of app %s' % app.app_id)
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:11,代碼來源:delete_service.py

示例3: get

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
    def get(self):
        data_dict, app_user = self.get_user_info()
        if not data_dict or not app_user:
            return

        azzert(data_dict['a'] == "unsubscribe deactivate")

        app, user_profile = db.get([App.create_key(get_app_id_from_app_user(app_user)),
                                    UserProfile.createKey(app_user)])

        if not user_profile:
            self.redirect("/")
            return

        mobiles = list(get_user_active_mobiles(app_user))
        if mobiles:
            mobile = mobiles[0]
            if mobile.type in Mobile.ANDROID_TYPES:
                page_type = "android"
            elif mobile.type in Mobile.IOS_TYPES:
                page_type = "ios"
            else:
                return self.return_error()
        else:
            mobile = None
            page_type = "web"

        page_type = self.request.get("page_type", page_type)
        language = self.request.get("language", user_profile.language)

        ActivationLog(timestamp=now(), email=app_user.email(), mobile=mobile,
                      description="Visit unsubscribe page %s %s" % (page_type, user_profile.language)).put()

        jinja_template = self.get_jinja_environment().get_template('unsubscribe_deactivate.html')

        params = {
            'name': data_dict['n'],
            'app_name': get_app_by_user(app_user).name,
            'hide_header': True,
            'data': self.request.get("data"),
            'app_email': app_user.email(),
            'email': get_human_user_from_app_user(app_user).email(),
            'action': data_dict['a'],
            'page_type': page_type,
            'language': language,
            'is_city_app': app.type == App.APP_TYPE_CITY_APP
        }

        self.response.out.write(jinja_template.render(params))
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:51,代碼來源:unsubscribe_reminder_service.py

示例4: trans

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
 def trans(create_app_to):
     app_key = App.create_key(create_app_to.app_id)
     if App.get(app_key):
         raise DuplicateAppIdException(create_app_to.app_id)
     app = App(
         key=app_key,
         type=data.type,
         name=create_app_to.name,
         is_default=False,
         android_app_id=u'com.mobicage.rogerthat.%s' % create_app_to.app_id.replace('-', '.'),
         dashboard_email_address=data.dashboard_email_address,
         creation_time=now(),
     )
     app_settings = AppSettings(key=AppSettings.create_key(app.app_id),
                                background_fetch_timestamps=[21600] if app.type == App.APP_TYPE_CITY_APP else [])
     db.put((app, app_settings))
     return app
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:19,代碼來源:app.py

示例5: setup_qr_templates

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
    def setup_qr_templates(self, app_id):
        app = App.get(App.create_key(app_id))
        app.qrtemplate_keys = list()

        description = u"DEFAULT"
        key_name = create_qr_template_key_name(app_id, description)
        store_template(None, DEFAULT_QR_CODE_OVERLAY, description, u"".join(("%X" % c).rjust(2, '0')
                                                                            for c in DEFAULT_QR_CODE_COLOR), key_name)
        app.qrtemplate_keys.append(key_name)

        description = u"HAND"
        key_name = create_qr_template_key_name(app_id, description)
        store_template(None, HAND_ONLY_QR_CODE_OVERLAY, description, u"".join(("%X" % c).rjust(2, '0')
                                                                              for c in DEFAULT_QR_CODE_COLOR), key_name)
        app.qrtemplate_keys.append(key_name)

        put_and_invalidate_cache(app)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:19,代碼來源:mc_unittest.py

示例6: _send_export_email

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def _send_export_email(result_path, human_user_email, app_id, data_export_email, download_url):
    logging.info(download_url)
    app_user = create_app_user_by_email(human_user_email, app_id)
    user_profile, app = db.get([get_profile_key(app_user), App.create_key(app_id)])

    subject = localize(user_profile.language, "user_data_download_ready_summary")
    variables = dict(name=user_profile.name,
                     link=download_url,
                     app=app)
    body = render("data_download_ready_email", [user_profile.language], variables)
    html = render("data_download_ready_email_html", [user_profile.language], variables)
    server_settings = get_server_settings()

    email_receivers = [data_export_email]
    if app.is_default:
        email_sender = server_settings.senderEmail
    else:
        email_sender = ("%s <%s>" % (app.name, app.dashboard_email_address))

    send_mail(email_sender, email_receivers, subject, body, html=html)
    deferred.defer(_cleanup_export, result_path, _countdown=4 * DAY, _queue=DATA_EXPORT_QUEUE)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:23,代碼來源:export.py

示例7: send_email

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def send_email(app_user_email, stats, dry_run=True):
    # stats: (index, {(sender_user, message_content, broadcast_type, timestamp), ...})
    app_user = users.User(app_user_email)
    app_id = get_app_id_from_app_user(app_user)
    user_profile, app = db.get([get_profile_key(app_user), App.create_key(app_id)])
    if app.type in (App.APP_TYPE_YSAAA, App.APP_TYPE_OSA_LOYALTY):
        logging.debug("App type was %s: %s", app.type_str, app_user.email())
        return

    if not user_profile:
        logging.info("User was deactivated: %s" , app_user.email())
        return

    if user_profile.unsubscribed_from_reminder_email:
        logging.info("User unsubscribed from email reminders: %s" , app_user.email())
        return

    language = convert_web_lang_to_iso_lang(user_profile.language or DEFAULT_LANGUAGE)
    try:
        Locale.parse(language)
    except UnknownLocaleError:
        language = DEFAULT_LANGUAGE

    human_user, app_id = get_app_user_tuple_by_email(app_user_email)
    human_user_email = human_user.email()

    app = get_app_by_id(app_id)
    server_settings = get_server_settings()

    text_params, html_params, avatars = _get_template_params(stats, language, server_settings, user_profile,
                                                             human_user_email, app)

    jinja_template = JINJA_ENVIRONMENT.get_template('generic/unread_messages_notification_email.tmpl')
    body = jinja_template.render(text_params)

    jinja_template = JINJA_ENVIRONMENT.get_template('generic/unread_messages_notification_email_html.tmpl')
    html = jinja_template.render(html_params)

    logging.info("%sSending mail to %s\n%s", 'DRY RUN!\n\n' if dry_run else '', human_user_email, body)

    email_receivers = server_settings.supportWorkers if dry_run else [human_user_email]
    if app.is_default:
        email_sender = server_settings.senderEmail
    else:
        email_sender = ("%s <%s>" % (app.name, app.dashboard_email_address))

    rel_mime = MIMEMultipart('related')
    rel_mime['Subject'] = text_params['title']
    rel_mime['From'] = email_sender
    rel_mime['To'] = ', '.join(email_receivers)

    msg = MIMEMultipart('alternative')
    msg.attach(MIMEText(body.encode('utf-8'), 'plain', 'utf-8'))
    msg.attach(MIMEText(html.encode('utf-8'), 'html', 'utf-8'))
    rel_mime.attach(msg)

    for avatar_id, avatar_data in avatars.iteritems():
        mime_img = MIMEImage(avatar_data, 'png')
        mime_img.add_header('Content-Id', '<%s>' % avatar_id)
        mime_img.add_header("Content-Disposition", "inline", filename="%s.png" % avatar_id)
        rel_mime.attach(mime_img)

    send_mail_via_mime(email_sender, email_receivers, rel_mime)

    if DEBUG and dry_run:
        return html
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:68,代碼來源:send_unread_messages.py

示例8: setUp

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
    def setUp(self, datastore_hr_probability=0):
        from rogerthat.bizz.profile import create_user_profile
        from rogerthat.settings import get_server_settings
        from rogerthat.rpc import users
        from google.appengine.datastore import datastore_stub_util
        from google.appengine.ext import testbed
        from rogerthat_tests import register_tst_mobile
        from rogerthat.to.payment import PaymentProviderTO
        from rogerthat.bizz.payment import create_payment_provider

        os.environ['HTTP_HOST'] = 'rt.dev:8080'

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.datastore_hr_policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(
            probability=datastore_hr_probability)
        self.testbed.init_datastore_v3_stub(consistency_policy=self.datastore_hr_policy)
        self.testbed.init_taskqueue_stub(root_path=os.path.join(os.path.dirname(__file__), '..', 'src'))
        self.task_queue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
        self.testbed.init_channel_stub()
        self.testbed.init_search_stub()
        self.testbed.init_blobstore_stub()

        ss = get_server_settings()
        ss.baseUrl = "http://localhost:8080"  # not used
        ss.mobidickAddress = "http://1.2.3.4:8090"  # not used
        ss.jabberEndPoints = ["jabber.example.com:8084"]  # Development jabber server
        ss.jabberSecret = "leeg"
        ss.userCodeCipher = u"dGVzdCAlcyB0ZXN0"
        ss.dashboardEmail = u"[email protected]"
        ss.supportEmail = u"[email protected]"
        ss.supportWorkers = ["[email protected]"]
        ss.serviceCreators = ["djmatic", "[email protected]", "", "[email protected]"]
        ss.staticPinCodes = ["0666", "[email protected]"]
        ss.userEncryptCipherPart1 = base64.b64encode(u'userEncryptCipherPart1')
        ss.userEncryptCipherPart2 = base64.b64encode(u'userEncryptCipherPart2')

        rogerthat_app = App(key=App.create_key(u"rogerthat"))
        rogerthat_app.name = u"Rogerthat"
        rogerthat_app.type = App.APP_TYPE_ROGERTHAT
        rogerthat_app.core_branding_hash = None
        rogerthat_app.facebook_app_id = 188033791211994
        rogerthat_app.ios_app_id = u"id446796149"
        rogerthat_app.android_app_id = u"com.mobicage.rogerth.at"
        rogerthat_app.secure = True
        rogerthat_app.is_default = True
        rogerthat_app.visible = True
        rogerthat_app.creation_time = now()
        rogerthat_app.admin_services = [u'[email protected]']
        rogerthat_app.mdp_client_id = str(uuid.uuid4())
        rogerthat_app.mdp_client_secret = str(uuid.uuid4())

        be_loc_app = App(key=App.create_key(u"be-loc"))
        be_loc_app.name = u"Lochristi"
        be_loc_app.type = App.APP_TYPE_CITY_APP
        be_loc_app.core_branding_hash = None
        be_loc_app.facebook_app_id = 188033791211994
        be_loc_app.ios_app_id = u"com.mobicage.cityapp.lochristi"
        be_loc_app.android_app_id = u"com.mobicage.cityapp.lochristi"
        be_loc_app.creation_time = now()
        be_loc_app.secure = False
        be_loc_app.is_default = False
        be_loc_app.visible = True
        be_loc_app.mdp_client_id = str(uuid.uuid4())
        be_loc_app.mdp_client_secret = str(uuid.uuid4())

        be_berlare_app = App(key=App.create_key(u"be-berlare"))
        be_berlare_app.name = u"Berlare"
        be_berlare_app.type = App.APP_TYPE_CITY_APP
        be_berlare_app.core_branding_hash = None
        be_berlare_app.facebook_app_id = None
        be_berlare_app.ios_app_id = u"com.mobicage.cityapp.berlare"
        be_berlare_app.android_app_id = u"com.mobicage.cityapp.berlare"
        be_berlare_app.creation_time = now()
        be_berlare_app.secure = False
        be_berlare_app.is_default = False
        be_berlare_app.visible = True
        be_berlare_app.mdp_client_id = str(uuid.uuid4())
        be_berlare_app.mdp_client_secret = str(uuid.uuid4())

        osa_loyalty_app = App(key=App.create_key(u"osa-loyalty"))
        osa_loyalty_app.name = u"OSA Loyalty"
        osa_loyalty_app.type = App.APP_TYPE_CONTENT_BRANDING
        osa_loyalty_app.core_branding_hash = None
        osa_loyalty_app.facebook_app_id = 188033791211994
        osa_loyalty_app.ios_app_id = u"com.mobicage.rogerthat.osa.loyalty"
        osa_loyalty_app.android_app_id = u"com.mobicage.rogerthat.osa.loyalty"
        osa_loyalty_app.creation_time = now()
        osa_loyalty_app.is_default = False
        osa_loyalty_app.visible = True

        put_and_invalidate_cache(ss, rogerthat_app, be_loc_app, be_berlare_app, osa_loyalty_app)

        create_payment_provider(PaymentProviderTO(id=u"payconiq",
                                                  name=u"Payconiq",
                                                  logo=None,
                                                  version=1,
                                                  description=u"payconiq descripion is markdown",
                                                  oauth_settings=None,
                                                  background_color=None,
#.........這裏部分代碼省略.........
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:103,代碼來源:mc_unittest.py

示例9: post

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
    def post(self):
        success = False
        app_id = self.request.POST.get("app_id", None)
        name = self.request.POST.get("name", None)
        app_type = self.request.POST.get("app_type", None)
        fb_app_id = self.request.POST.get("fb_app_id", None)
        ios_app_id = self.request.POST.get("ios_app_id", None)
        android_app_id = self.request.POST.get("android_app_id", None)
        dashboard_email_address = self.request.POST.get('dashboard_email_address', None)
        contact_email_address = self.request.POST.get("contact_email_address", None)
        user_regex = self.request.POST.get("user_regex", None)
        qr_templates_count = int(self.request.POST.get("qr_templates_count", 0))
        default_qr_template_index = int(self.request.POST.get("default_qr_template_index", 0))
        auto_connected_services_string = self.request.POST.get("auto_connected_services", "[]")
        logging.debug("auto_connected_services = %s", auto_connected_services_string)
        beacon_major_str = self.request.POST.get("beacon_major", 0)
        beacon_major = int(beacon_major_str) if beacon_major_str else 0
        demo = bool(self.request.POST.get("demo", ''))
        beta = bool(self.request.POST.get("beta", ''))
        mdp_client_id = self.request.POST.get('mdp_client_id', None)
        mdp_client_secret = self.request.POST.get('mdp_client_secret', None)
        orderable_apps = self.request.get_all('orderable_apps')
        auto_connected_services = parse_complex_value(AutoConnectedService,
                                                      json.loads(auto_connected_services_string),
                                                      True)
        admin_services = json.loads(self.request.POST.get('admin_services', '[]'))
        beacon_regions = json.loads(self.request.POST.get("beacon_regions", "[]"))

        try:
            app_type = None if not app_type else int(app_type)
        except Exception:
            app_type = None

        try:
            fb_app_id = None if not fb_app_id else int(fb_app_id)
        except Exception:
            fb_app_id = None

        if not app_id:
            result = "Failed to create new app (app_id was empty)!"
        elif [c for c in app_id if c not in '-abcdefghijklmnopqrstuvwxyz0123456789']:
            result = "App ids should only contain (-, lower case alphabet characters and numbers)"
        elif not name:
            result = "Failed to create new app (name was empty)!"
        elif app_type is None:
            result = "Failed to create new app (app_type was empty)!"
        elif not ios_app_id:
            result = "Failed to create new app (ios_app_id was empty)!"
        elif not android_app_id:
            result = "Failed to create new app (android_app_id was empty)!"
        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))
#.........這裏部分代碼省略.........
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:103,代碼來源:apps.py

示例10: get_app_by_id

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def get_app_by_id(app_id):
    # type: (unicode) -> App
    return get_cached_model(App.create_key(app_id))
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:5,代碼來源:app.py

示例11: get_apps_by_id

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def get_apps_by_id(app_ids):
    # type: (list[unicode]) -> list[App]
    return get_cached_models([App.create_key(app_id) for app_id in app_ids])
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:5,代碼來源:app.py

示例12: get_app_and_translations_by_app_id

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def get_app_and_translations_by_app_id(app_id):
    return AppAndTranslations(*db.get((App.create_key(app_id), AppTranslations.create_key(app_id))))
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:4,代碼來源:app.py

示例13: get_app_by_id

# 需要導入模塊: from rogerthat.models import App [as 別名]
# 或者: from rogerthat.models.App import create_key [as 別名]
def get_app_by_id(app_id):
    return App.get(App.create_key(app_id))
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:4,代碼來源:app.py


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