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


Python Site.put方法代码示例

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


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

示例1: add_site

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import put [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 )
开发者ID:evdb,项目名称:Privatar,代码行数:31,代码来源:site.py

示例2: _create_example_site

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import put [as 别名]
def _create_example_site(user):
    site = Site(
        name='Example Site',
        owner = user,
        users = [user],
        admins = [user],
        example = True,
    )
    site.put()

    for v in [4, 5]:
        name = 'Html%d Example' % v
        style = Style(site=site, name=name)
        style.put()
        rev = StyleRevision(parent=style, rev=0)
        rev.put()
        rev.update(render_template('examples/blog-html%d.css' % v))
        style.published_rev = rev
        rev = StyleRevision(parent=style, rev=1)
        rev.put()
        rev.update(render_template('examples/blog-html%d-preview.css' % v))
        style.preview_rev = rev
        style.put()
        page = Page(site=site, name=name, url=url_for('example%d' % v, page_key=0, _external=True), _styles=[style.key()])
        page.put()
        page.url = url_for('example%d' % v, page_key=page.key(), _external=True)
        page.put()
        page.queue_refresh()
开发者ID:1ncnspcuous,项目名称:WebPutty,代码行数:30,代码来源:views.py

示例3: put

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import put [as 别名]
    def put(self, name):
        "Updates or Creates are managed through put on the name"

        # get the json from the body of the request
        json = self.request.body
        # convert the JSON to a Python object
        representation = simplejson.loads(json)
        # set the properties
        url = representation["url"]
        email = representation["email"]

        # we need to check whether this is an update
        try:
            site = Site.gql("WHERE name=:1", name)[0]
            site.url = url
            site.email = email
        except IndexError:
            # or a create
            site = Site(name=name, url=db.Link(url), email=db.Email(email))
        # either way we need to save the new object
        site.put()
开发者ID:rootart,项目名称:appengine-uptime,代码行数:23,代码来源:main.py

示例4: new_site

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import put [as 别名]
def new_site():
    user = users.get_current_user()
    form = PageForm(request.form)
    if request.method == 'POST':
        if form.validate():
            site = Site(
                name = form.name.data,
                owner = user,
                users = [user],
                admins = [user],
            )
            site.put()
            page = Page.new_page(site, form.name.data, form.url.data)
            new_url = url_for('editor', page_id=page.key().id())
            if request.is_xhr:
                return jsonify(dict(type='success', redirect=new_url))
            else:
                return redirect(new_url)
        elif request.is_xhr:
            return jsonify(dict(type='error', errors=render_template('form_errors.html', form=form)))
    if request.is_xhr:
        return render_template('site_creator.html', form=form)
    return render_template('new_site.html', form=form)
开发者ID:1ncnspcuous,项目名称:WebPutty,代码行数:25,代码来源:views.py

示例5: post

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import put [as 别名]
    def post(self):
        
        """
        site = Site(
            name = 'name',
            url = 'http://url.com',            
            slug = 'slug',
        )
        site.put()
        
        issue = Issue(
            title = 'title',
            description = 'description',
            site = site,
        )
        issue.put()
        """

        # get url and then decide if we have a site already or
        # need to create one
        
        
        
        name = self.request.get("name")
        url = self.request.get("url")
        
        try:
            site = Site.gql("WHERE url=:1", url)[0]
        except IndexError:
            
            """
            import sys
            import pdb
            for attr in ('stdin', 'stdout', 'stderr'):
                setattr(sys, attr, getattr(sys, '__%s__' % attr))
            pdb.set_trace()
            """
            
            site = Site(
                name = name,
                url = url,            
                slug = slugify(name),
            )
            site.put()

        title = self.request.get("title")
        description = self.request.get("description")

        issue = Issue(
            title = title,
            description = description,
            site = site,
        )
        issue.put()


        context = {
            'issue': issue,
            'sites': Site.all(),
        }

        # prepare the context for the template
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), 'templates',
            'index.html')
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
开发者ID:4sp1r3,项目名称:fixmysite,代码行数:69,代码来源:main.py

示例6: Site

# 需要导入模块: from models import Site [as 别名]
# 或者: from models.Site import put [as 别名]
import urllib2
import httplib
from BeautifulSoup import BeautifulStoneSoup as bs
import logging
from titlecase import titlecase
from random import randint
import __init__ as zeep
import time
from qlsearch import QLSearch
from lyricsscrape import androidSearch, scrapeSongID

SECRET_ACCESS_KEY = '8c52658c67d395ae2a7f40ccbe76f4353b648c09'
API_KEY = '920dc163-c83c-4d50-9e09-c24b2b6b568d'

s = Site(name ='lyricsfreak', type='lyrics',tag = 'a', div='a', siteName='lyricsfreak')
s.put()
# s.commit()


class getLyricsHandler( webapp.RequestHandler ):
    def get( self ):
        try:
            city = self.request.get( 'city' )
            state = self.request.get( 'state' )
            country = self.request.get( 'country' )
            songID = self.request.get('songid')
            type_ = self.request.get('contenttype')
            term = self.request.get('songTitle')
            if not type_:
                type_ = 'lyrics'
            if songID:
开发者ID:jackdreilly,项目名称:quiklyrics,代码行数:33,代码来源:helloworld.py


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