本文整理匯總了Python中models.Site.is_code_taken方法的典型用法代碼示例。如果您正苦於以下問題:Python Site.is_code_taken方法的具體用法?Python Site.is_code_taken怎麽用?Python Site.is_code_taken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Site
的用法示例。
在下文中一共展示了Site.is_code_taken方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_site
# 需要導入模塊: from models import Site [as 別名]
# 或者: from models.Site import is_code_taken [as 別名]
def add_site(self):
self.template_path = 'site_add.html'
# get the site code
site_code = self.request.get('site_code').strip()
self.vars['site_code'] = site_code
# return if there is no site_code, or we are not a post
if (not site_code) or self.request.method != 'POST' :
return
# check that the site_code is valid
if not Site.is_code_valid( site_code ):
self.vars['site_code_error'] = "site code is not valid"
return
# check that the site_code is valid
if Site.is_code_taken( site_code ):
self.vars['site_code_error'] = "site code already exists"
return
# ok to create
site = Site( site_code=site_code, owner=self.person )
site.put()
# create the first shared secret
SharedSecret.new_for_site( site )
self.redirect('/site/' + site_code )