• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_message函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.get_message函数的典型用法代码示例。如果您正苦于以下问题:Python get_message函数的具体用法?Python get_message怎么用?Python get_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: POST

 def POST(self, key):
     i = web.input(v=None, _method="GET")
     v = i.v and safeint(i.v, None)
     edition = web.ctx.site.get(key, v)
     
     if edition is None:
         raise web.notfound()
     if edition.works:
         work = edition.works[0]
     else:
         work = None
         
     add = (edition.revision == 1 and work and work.revision == 1 and work.edition_count == 1)
         
     try:    
         helper = SaveBookHelper(work, edition)
         helper.save(web.input())
         
         if add:
             add_flash_message("info", utils.get_message("flash_book_added"))
         else:
             add_flash_message("info", utils.get_message("flash_book_updated"))
         
         raise web.seeother(edition.url())
     except (ClientException, ValidationException), e:
         raise
         add_flash_message('error', str(e))
         return self.GET(key)
开发者ID:amoghravish,项目名称:openlibrary,代码行数:28,代码来源:addbook.py


示例2: POST

    def POST(self, key):
        i = web.input(v=None, _method="GET")

        if spamcheck.is_spam():
            return render_template("message.html", 
                "Oops",
                'Something went wrong. Please try again later.')

        recap_plugin_active = is_plugin_enabled('recaptcha')

        #check to see if account is more than two years old
        old_user = False
        user = web.ctx.site.get_user()
        account = user and user.get_account()
        if account:
            create_dt = account.creation_time()
            now_dt = datetime.datetime.utcnow()
            delta = now_dt - create_dt
            if delta.days > 365*2:
                old_user = True

        if recap_plugin_active and not old_user:
            public_key = config.plugin_recaptcha.public_key
            private_key = config.plugin_recaptcha.private_key
            recap = recaptcha.Recaptcha(public_key, private_key)

            if not recap.validate():
                return 'Recaptcha solution was incorrect. Please <a href="javascript:history.back()">go back</a> and try again.'

        v = i.v and safeint(i.v, None)
        edition = web.ctx.site.get(key, v)

        if edition is None:
            raise web.notfound()
        if edition.works:
            work = edition.works[0]
        else:
            work = None

        add = (edition.revision == 1 and work and work.revision == 1 and work.edition_count == 1)

        try:
            helper = SaveBookHelper(work, edition)
            helper.save(web.input())

            if add:
                add_flash_message("info", utils.get_message("flash_book_added"))
            else:
                add_flash_message("info", utils.get_message("flash_book_updated"))

            raise web.seeother(edition.url())
        except (ClientException, ValidationException), e:
            add_flash_message('error', str(e))
            return self.GET(key)
开发者ID:harshadsavant,项目名称:openlibrary,代码行数:54,代码来源:addbook.py


示例3: no_match

 def no_match(self, i):
     # TODO: Handle add-new-author
     work = new_doc("/type/work",
         title=i.title,
         authors=[{"author": {"key": i.author_key}}]
     )
     comment = utils.get_message("comment_new_work")
     work._save(comment)
     
     edition = self._make_edition(work, i)
     comment = utils.get_message("comment_new_edition")
     edition._save(comment)        
     raise web.seeother(edition.url("/edit?mode=add-work"))
开发者ID:balinjdl,项目名称:openlibrary,代码行数:13,代码来源:addbook.py


示例4: POST

    def POST(self, key):
        i = web.input(v=None, _method="GET")

        if spamcheck.is_spam():
            return render_template("message.html",
                "Oops",
                'Something went wrong. Please try again later.')

        recap = get_recaptcha()

        if recap and not recap.validate():
            return render_template("message.html",
                'Recaptcha solution was incorrect',
                'Please <a href="javascript:history.back()">go back</a> and try again.'
            )

        v = i.v and safeint(i.v, None)
        work = web.ctx.site.get(key, v)
        if work is None:
            raise web.notfound()

        try:
            helper = SaveBookHelper(work, None)
            helper.save(web.input())
            add_flash_message("info", utils.get_message("flash_work_updated"))
            raise web.seeother(work.url())
        except (ClientException, ValidationException) as e:
            add_flash_message('error', str(e))
            return self.GET(key)
开发者ID:internetarchive,项目名称:openlibrary,代码行数:29,代码来源:addbook.py


示例5: POST

    def POST(self, key):
        i = web.input(v=None, _method="GET")

        recap_plugin_active = 'recaptcha' in config.get('plugins')
        if recap_plugin_active:
            public_key = config.plugin_recaptcha.public_key
            private_key = config.plugin_recaptcha.private_key
            recap = recaptcha.Recaptcha(public_key, private_key)

            if not recap.validate():
                return 'Recaptcha solution was incorrect. Please <a href="javascript:history.back()">go back</a> and try again.'

        v = i.v and safeint(i.v, None)
        work = web.ctx.site.get(key, v)
        if work is None:
            raise web.notfound()

        try:
            helper = SaveBookHelper(work, None)
            helper.save(web.input())
            add_flash_message("info", utils.get_message("flash_work_updated"))
            raise web.seeother(work.url())
        except (ClientException, ValidationException), e:
            add_flash_message('error', str(e))
            return self.GET(key)
开发者ID:Web5design,项目名称:openlibrary,代码行数:25,代码来源:addbook.py


示例6: work_match

    def work_match(self, saveutil, work, i):
        edition = self._make_edition(work, i)
        
        saveutil.save(edition)
        comment = utils.get_message("comment_add_book")
        saveutil.commit(comment=comment, action="add-book")

        raise web.seeother(edition.url("/edit?mode=add-book"))
开发者ID:amoghravish,项目名称:openlibrary,代码行数:8,代码来源:addbook.py


示例7: find_matches

    def find_matches(self, saveutil, i):
        """Tries to find an edition or a work or multiple works that match the given input data.
        
        Case#1: No match. None is returned.
        Case#2: Work match but not editon. Work is returned.
        Case#3: Work match and edition match. Edition is returned
        Case#3A: Work match and multiple edition match. List of works is returned
        Case#4: Multiple work match. List of works is returned. 
        """
        i.publish_year = i.publish_date and self.extract_year(i.publish_date)
        
        work_key = i.get('work')
        
        # work_key is set to none-of-these when user selects none-of-these link.
        if work_key == 'none-of-these':
            return None
            
        work = work_key and web.ctx.site.get(work_key)
        if work:
            edition = self.try_edition_match(work=work, 
                publisher=i.publisher, publish_year=i.publish_year, 
                id_name=i.id_name, id_value=i.id_value)
            return edition or work
        
        if i.author_key == "__new__":
            a = new_doc("/type/author", name=i.author_name)
            comment = utils.get_message("comment_new_author")
            saveutil.save(a)
            i.author_key = a.key
            # since new author is created it must be a new record
            return None
            
        edition = self.try_edition_match(
            title=i.title, 
            author_key=i.author_key,
            publisher=i.publisher,
            publish_year=i.publish_year,
            id_name=i.id_name,
            id_value=i.id_value)
            
        if edition:
            return edition

        solr = get_works_solr()
        author_key = i.author_key and i.author_key.split("/")[-1]
        result = solr.select({'title': i.title, 'author_key': author_key}, doc_wrapper=make_work, q_op="AND")
        
        if result.num_found == 0:
            return None
        elif result.num_found == 1:
            return result.docs[0]
        else:
            return result.docs
开发者ID:amoghravish,项目名称:openlibrary,代码行数:53,代码来源:addbook.py


示例8: no_match

    def no_match(self, saveutil, i):
        # TODO: Handle add-new-author
        work = new_doc("/type/work", title=i.title, authors=[{"author": {"key": i.author_key}}])

        edition = self._make_edition(work, i)

        saveutil.save(work)
        saveutil.save(edition)

        comment = utils.get_message("comment_add_book")
        saveutil.commit(action="add-book", comment=comment)

        raise web.seeother(edition.url("/edit?mode=add-work"))
开发者ID:artmedlar,项目名称:openlibrary,代码行数:13,代码来源:addbook.py


示例9: POST

    def POST(self, key):
        i = web.input(v=None, _method="GET")

        if spamcheck.is_spam():
            return render_template("message.html", 
                "Oops",
                'Something went wrong. Please try again later.')

        recap = get_recaptcha()

        if recap and not recap.validate():
            return 'Recaptcha solution was incorrect. Please <a href="javascript:history.back()">go back</a> and try again.'

        v = i.v and safeint(i.v, None)
        edition = web.ctx.site.get(key, v)

        if edition is None:
            raise web.notfound()
        if edition.works:
            work = edition.works[0]
        else:
            work = None

        add = (edition.revision == 1 and work and work.revision == 1 and work.edition_count == 1)

        try:
            helper = SaveBookHelper(work, edition)
            helper.save(web.input())

            if add:
                add_flash_message("info", utils.get_message("flash_book_added"))
            else:
                add_flash_message("info", utils.get_message("flash_book_updated"))

            raise web.seeother(edition.url())
        except (ClientException, ValidationException), e:
            add_flash_message('error', str(e))
            return self.GET(key)
开发者ID:bfalling,项目名称:openlibrary,代码行数:38,代码来源:addbook.py


示例10: save

    def save(self, formdata):
        """Update work and edition documents according to the specified formdata."""
        comment = formdata.pop('_comment', '')

        user = web.ctx.site.get_user()
        delete = user and user.is_admin() and formdata.pop('_delete', '')
        
        formdata = utils.unflatten(formdata)
        work_data, edition_data = self.process_input(formdata)
        
        self.process_new_fields(formdata)
        
        if delete:
            if self.edition:
                self.delete(self.edition.key, comment=comment)
            
            if self.work and self.work.edition_count == 0:
                self.delete(self.work.key, comment=comment)
            return
            
        for i, author in enumerate(work_data.get("authors") or []):
            if author['author']['key'] == "__new__":
                a = self.new_author(formdata['authors'][i])
                a._save(utils.get_message("comment_new_author"))
                author['author']['key'] = a.key
                    
        if work_data:
            if self.work is None:
                self.work = self.new_work(self.edition)
                self.edition.works = [{'key': self.work.key}]
            self.work.update(work_data)
            self.work._save(comment=comment)
            
        if self.edition and edition_data:
            identifiers = edition_data.pop('identifiers', [])
            self.edition.set_identifiers(identifiers)
            
            classifications = edition_data.pop('classifications', [])
            self.edition.set_classifications(classifications)
            
            self.edition.set_physical_dimensions(edition_data.pop('physical_dimensions', None))
            self.edition.set_weight(edition_data.pop('weight', None))
            self.edition.set_toc_text(edition_data.pop('table_of_contents', ''))
            
            if edition_data.pop('translation', None) != 'yes':
                edition_data.translation_of = None
                edition_data.translated_from = None
            
            self.edition.update(edition_data)
            self.edition._save(comment=comment)
开发者ID:balinjdl,项目名称:openlibrary,代码行数:50,代码来源:addbook.py


示例11: make_index_file

def make_index_file(date, audio_fname_list, output_fname=None):
    import datetime
    import os

    import schedule
    import utils
    from rsab.listenagain import config, ListenAgainConfigError
    if not config.has_option('DEFAULT', 'output'):
        raise ListenAgainConfigError('No [DEFAULT]/output config defined')

    if output_fname is None:
        output_fname = 'index.html'
    output_fname = os.path.join(config.get('DEFAULT', 'output'), output_fname)
    output_file = open(output_fname, 'w')

    template = Template('player')

    playlist_items = []
    details_for_audio_files = []
    show_name_mapping = {}
    presenter_name_mapping = {}
    for audio_fname in audio_fname_list:
        playlist_items.append(str(make_playlist_item(audio_fname)))
        details_for_audio_files.append(schedule.schedule_from_audio_file_name(audio_fname))

    live_schedule = schedule.get_schedule(date + datetime.timedelta(days=1))
    for details in details_for_audio_files + live_schedule:
        if details is None:
            continue
        show_name = details['show']
        show_title = utils.get_message(show_name, 'show', default=None)
        if show_title is None:
            show_title = utils.get_message(show_name, 'presenter', default=show_name)
        if show_name and show_name not in show_name_mapping:
            show_name_mapping[show_name] = show_title
        for presenter in details.get('presenters', []):
            if not presenter or presenter == show_name:
                continue
            if presenter not in presenter_name_mapping:
                presenter_name_mapping[presenter] = utils.get_message(presenter, 'presenter', default=presenter)

    template.playlist_items = '\n'.join(filter(None, playlist_items))
    hidden_input = '<input type="hidden" disabled="disabled" name="%s" value="%s" />'
    template.show_name_mapping = '\n'.join([
        hidden_input % ('showname', '%s:%s' % pair)
        for pair in show_name_mapping.items()
    ])
    template.presenter_name_mapping = '\n'.join([
        hidden_input % ('presentername', '%s:%s' % pair)
        for pair in presenter_name_mapping.items()
    ])
    template.live_schedule = '\n'.join([
        hidden_input % (
            'live_schedule',
            '%s:%s' % (
                details['start'].strftime('%H:%M'),
                ','.join([details['show']] + details.get('presenters', [])),
            ),
        )
        for details in schedule.get_schedule(date + datetime.timedelta(days=1))
    ])

    output_file.write(str(template))
    output_file.close()
    return output_fname
开发者ID:radio-st-austell-bay,项目名称:listenagain,代码行数:65,代码来源:html.py


示例12: work_match

 def work_match(self, work, i):
     edition = self._make_edition(work, i)            
     comment = utils.get_message("comment_new_edition")
     edition._save(comment)
     raise web.seeother(edition.url("/edit?mode=add-book"))
开发者ID:balinjdl,项目名称:openlibrary,代码行数:5,代码来源:addbook.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_mongo_database函数代码示例发布时间:2022-05-26
下一篇:
Python utils.get_match_parent函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap