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


Python Member.gql方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import gql [as 别名]
    def post(self):
        if len(self.request.POST) == 4 and 'handle' in self.request.POST \
                and 'real_name' in self.request.POST \
                and 'email' in self.request.POST \
                and 'bio' in self.request.POST:

            handle = self.request.POST.getall('handle')[0]
            template_dict = {}
            member = Member.get_current_member()
            other = Member.gql('WHERE handle = :1', handle).get()

            if (not handle or len(handle) > 12 or
                any(l not in self.valid_letters for l in handle)):
                template_dict['error'] = 'Pick something sensible, you moron.'

            elif other and other.user_id != member.user_id:
                template_dict['error'] = 'Sorry, already taken.'

            elif handle.lower() in self.banned_names:
                template_dict['error'] = self.banned_names[handle]

            else:
                real_name = self.request.POST.getall('real_name')[0]
                if real_name:
                    member.real_name = real_name
                email = self.request.POST.getall('email')[0]
                if email:
                    member.email = email
                bio = self.request.POST.getall('bio')[0]
                if bio:
                    member.bio = bio
                member.handle = handle
                member.save()
                template_dict['error'] = 'Profile updated'
            self.render_template('account', template_dict)
开发者ID:Man-UP,项目名称:website,代码行数:37,代码来源:handlers.py

示例2: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import gql [as 别名]
 def get(self, handle):
     query = Member.gql('WHERE handle = :1', urllib.unquote(handle))
     member = iter(query).next() if query.count() else None
     member_talks = TalkNew.all().filter('member = ', member)
     self.render_template('member', {
         'member': member,
         'member_talks' : member_talks
     })
开发者ID:Man-UP,项目名称:website,代码行数:10,代码来源:handlers.py

示例3: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import gql [as 别名]
 def get(self):
     handle = self.request.get('handle', None)
     if handle is None:
         # First request, just get the first handle out of the datastore.
         hacker = Hacker.gql('ORDER BY handle DESC').get()
         if not hacker:
             # No hackers in database
             self.response.headers['Content-Type'] = 'text/plain'
             self.response.out.write("No Hackers in database")
             return
         handle = hacker.handle
 
     query = Hacker.gql('WHERE handle <= :1 ORDER BY handle DESC', handle)
     hackers = query.fetch(limit=2)
     current_hacker = hackers[0]
     if len(hackers) == 2:
         next_handle = hackers[1].handle
         next_url = '/admin/hacker_migration?handle=%s' % urllib.quote(next_handle)
     else:
         next_handle = 'FINISHED'
         next_url = '/'  # Finished processing, go back to main page.
         
         
     awards_updated = 0
     talks_updated = 0
     updated_hacker = False
     # Add a new member if this Hacker has not been migrated
     if not Member.gql('WHERE handle = :1', current_hacker.handle).get():
         new_member = Member(user_id=current_hacker.user_id,
                             email=current_hacker.email,
                             handle=current_hacker.handle,
                             bio=current_hacker.bio,
                             real_name=current_hacker.real_name)
         new_member.put()
         
         # Find any award or talk entities that reference the old hacker 
         # and remap them
         awards = Award.gql('WHERE hacker = :1', current_hacker)
         for award in awards:
             award.member = new_member
             if hasattr(award, 'hacker'):
                 del award.hacker
             award.put()
             awards_updated += 1
         talks = Talk.gql('WHERE member = :1', current_hacker)
         for talk in talks:
             talk.member = new_member
             talk.put()
             talks_updated += 1
                 
         updated_hacker = True
 
     # Delete the Hacker
     current_hacker.delete()
 
     context = {
         'current_handle': handle,
         'updated_hacker': updated_hacker,
         'awards_updated': awards_updated,
         'talks_updated': talks_updated,
         'next_handle': next_handle,
         'next_url': next_url,
     }
     
     self.render_template('hacker_migration', context)
开发者ID:eldog,项目名称:man-up-website,代码行数:67,代码来源:hacker_migration.py

示例4: get

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import gql [as 别名]
 def get(self, handle):
     query = Member.gql('WHERE handle = :1', urllib.unquote(handle))
     member = iter(query).next() if query.count() else None
     self.render_template('member', {
         'member': member
     })
开发者ID:eldog,项目名称:man-up,代码行数:8,代码来源:handlers.py


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