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


Python Page.put方法代码示例

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


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

示例1: _create_example_site

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page 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

示例2: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
    def post(self,slug):
        page = Page.query(Page.slug == slug).get()
        if page:
            page.slug = slug
            page.title = self.request.get('title')
            page.text = self.request.get('text')
            page.prev = self.request.get('prev')
            page.next = self.request.get('next')
            page.doc  = self.request.get('doc')
            page.allowed = int(self.request.get('level'))
            page.put()

            self.redirect('/content/{}'.format(slug))
        
        else:
            page = Page(title = self.request.get('title'),
                        slug = slug,
                        author = users.get_current_user(),
                        text = self.request.get('text'),
                        prev = self.request.get('prev'),
                        next = self.request.get('next'),
                        doc = self.request.get('doc'),
                        allowed = int(self.request.get('level'))
                    )
            page.put()
        
            self.redirect('/content/{}'.format(slug))
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:29,代码来源:main.py

示例3: create_default_page

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
def create_default_page(page_title):
    default_text = ('This page is brand new. ' +
                    'You can edit it by clicking the link above.')

    page = Page(title=page_title, text=default_text)
    page.put()
    return page
开发者ID:DanAlbert,项目名称:miniwiki,代码行数:9,代码来源:main.py

示例4: index

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
def index(request):

  params = {}
  if settings.SHOWPAGES:
    pages = Page.all()
    pages.order("-modified")
    posts = pages.fetch(settings.SHOWPAGES)
    params['posts'] = posts
    return respond(request, 'base.html', params)
  else:
    home_category = 'Main'
    home_page = 'Home'

    page = db.GqlQuery("SELECT * FROM Page WHERE name = :1", home_page).get()
    if page == None:
      if users.get_current_user():
        category = db.GqlQuery("SELECT * FROM Category WHERE name = :1", home_category).get()
        if category == None:
          category = Category(name=home_category, sequence=1)
          category.put()

        page = Page(name=home_page, category=home_category, sequence=1, content='<h1>Home Page</h1><h5>Change me!</h5>')
        page.put()
      else:
        return HttpResponseRedirect(users.create_login_url(request.get_full_path()))

    return viewPage(request, 'Main', 'Home')
开发者ID:hollerith,项目名称:schoogle,代码行数:29,代码来源:views.py

示例5: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
    def post(self):
        item = None
        vals = {}
        try:
            # get all the incoming values
            section = Section.get( self.request.get('section') )
            name = self.request.get('name').strip()
            title = self.request.get('title').strip()
            content = self.request.get('content')
            type = self.request.get('type')
            label_raw = self.request.get('label_raw').strip()
            attribute_raw = util.make_attr_raw_string(
                {
                    'index-entry'   : self.request.get('index_entry'),
                    'has-comments'  : self.request.get('has_comments'),
                    'comments-open' : self.request.get('comments_open'),
                    }
                ).strip()

            # some pre-processing of the input params
            if name == '':
                name = util.urlify(self.request.get('title'))

            if self.request.get('key'):
                item = Page.get( self.request.get('key') )
                item.section = section
                item.name = name
                item.title = title
                item.content = content
                item.type = type
                item.label_raw = label_raw
                item.attribute_raw = attribute_raw
            else:
                item = Page(
                    section = section,
                    name = name,
                    title = title,
                    content = content,
                    type = type,
                    label_raw = label_raw,
                    attribute_raw = attribute_raw,
                    )

            # update and save this page
            item.set_derivatives()
            item.put()
            # once saved, regenerate certain section properties
            section.regenerate()
            # also, check that this section doesn't have duplicate content
            Task( params={ 'section_key': str(section.key()), 'name': item.name }, countdown=30, ).add( queue_name='section-check-duplicate-nodes' )
            self.redirect('.')
        except Exception, err:
            vals['item'] = self.request.POST
            vals['err'] = err
            vals['sections'] = Section.all()
            vals['types'] = models.type_choices
            self.template( 'page-form.html', vals, 'admin' );
开发者ID:ranginui,项目名称:kohacon,代码行数:59,代码来源:page.py

示例6: get_page

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
    def get_page(self, page):
        """Return a single page from the cloud store, storing it locally"""

        if not self.token:
            log.debug("No token")
            return None

        # get the folder contents
        metadata = self.get_metadata(page)
        if not metadata:
            return None

        markup = None
        for i in metadata['contents']:
            if not i['is_dir']:
                if os.path.basename(i['path']) in self.valid_indexes:
                    markup = i['path']
                    break

        if not markup:
            return None
        
        get_url = _urls.files % (markup, urllib.urlencode({"access_token": self.token}))
        log.debug(get_url)
        r = fetch(get_url)

        if r['status'] == 200:
            metadata = json.loads(r['x-dropbox-metadata'])
            try:
                headers, body, mime_type = parse_rfc822(r['data'])
            except Exception as e:
                log.error("Could not parse %s: %s" % (page, e))
                return None

            # mtime is taken from cloud store metadata
            mtime = parse_dropbox_date(metadata['modified'])
            ctime = headers.get('created', None)
            if ctime:
                ctime = datetime.fromtimestamp(parse_date(ctime))

            id = page.lower()
            params = {
                "id"       : id,
                "path"     : page,
                "ctime"    : ctime,
                "mtime"    : mtime,
                "title"    : headers.get('title', 'Untitled'),
                "tags"     : headers.get('tags', None),
                "body"     : body,
                "mime_type": mime_type,
                "headers"  : headers
            }
            p = Page(**params)
            p.put()
            memcache.set(params['id'], params['headers'], namespace=NS_PAGE_METADATA)
            return p
        return None
开发者ID:rcarmo,项目名称:yaki-gae,代码行数:59,代码来源:store.py

示例7: update_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
def update_pages():
    logging.info('-> updateing pages')
    from importing import get_docs_data
    docs = get_docs_data(Var.get_value('admin'),Var.get_value('password'))
    
    docs_by_keys = dict((doc['res_id'],doc) for doc in docs)
    updated_or_deleted = set()
    
    updated_cnt = deleted_cnt = created_cnt = 0  
    # updateing
    for page in Page.all():
        
        # delete
        if not page.res_id in docs_by_keys:
            page.delete()
            deleted_cnt+=1
            logging.info('page %s deleted'%page.res_id)
            updated_or_deleted.add( page.res_id )

        else:        
            doc = docs_by_keys[page.res_id]
            # update existing
            page.slug = doc['slug']
            page.lang = doc['lang']
            page.title = doc['title']
            page.etag = doc['etag']
            page.updated = doc['updated']
            page.content = get_doc_content(doc['src'])
            page.src = doc['src']
            page.edit_url = doc['edit_url']
            page.put()            
            logging.info('page %s updated'%doc['res_id'])            
            updated_cnt+=1        
            updated_or_deleted.add( page.res_id )
        
    # new pages
    new_pages_ids = set(docs_by_keys) - updated_or_deleted
    for new_page_id in new_pages_ids:
        doc = docs_by_keys[new_page_id]
        # create new page
        page = Page(key_name=doc['res_id'],
            slug = doc['slug'],
            lang = doc['lang'],
            title = doc['title'],
            etag = doc['etag'],
            updated = doc['updated'],
            src = doc['src'],
            edit_url = doc['edit_url'],
            content = get_doc_content(doc['src']),
        )
        page.put()        
        logging.info('page %s created'%doc['res_id'])
        created_cnt+=1
        
    logging.info('<- updateing pages updated=%s created=%s deleted=%s'%(updated_cnt, created_cnt, deleted_cnt))
开发者ID:ppalucki,项目名称:shcms,代码行数:57,代码来源:tasks.py

示例8: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
    def post(self, slug=None):
        if slug:
            page = Page.gql("WHERE slug = :1", slug).get()
        else:
            page = Page()
        page.title = self.request.get('title')
        page.slug = self.request.get('slug')
        page.content = self.request.get('content')
        page.order_in_menu = int(self.request.get('order_in_menu'))

        page.put()

        self.redirect(page.get_url())
开发者ID:ibz,项目名称:nuages,代码行数:15,代码来源:admin.py

示例9: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
    def post(self, path):
        if not self.user:
            self.error(400)
            return

        content = self.request.get('content')
        old_page = Page.by_path(path).get()
        if not (old_page or content):
            return
        elif not old_page or old_page.content != content:
            p = Page(parent=Page.parent_key(path), content=content)
            p.put()

        self.redirect(path)
开发者ID:michaelhuang,项目名称:udacity-cs253,代码行数:16,代码来源:handlers.py

示例10: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
 def post(self, page_name):
     page = Page.by_name(page_name)
     if self.user:
         body = self.request.get('content')
     else:  # if posted while not logged in.
         self.write('ERROR: not logged in.')
         self.abort()
     if not page:  # For creatubg a new page.
         page = Page(title=page_name)
         page.put()
     revision = Revision(body=body, user=self.user, parent=page)
     revision.put()
     page.revision = revision
     page.put()
     self.redirect_to('WikiPage', page_name=page_name)
开发者ID:romanlevin,项目名称:roman-wiki,代码行数:17,代码来源:wiki.py

示例11: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
  def post(self, ident=None):
    if ident:
      source = Page.fetch_by_key(ident)
    else:
      source = Page()

    source.name = self.request.get('name', '')
    source.url = self.request.get('url', '')
    source.phrases = self.request.get('phrases', '')
    key = source.put()
    self.response.write(key.urlsafe())
开发者ID:jabrouwer82,项目名称:creepy-kumquat,代码行数:13,代码来源:sources.py

示例12: fetch_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
def fetch_pages(user):
  api = FacebookAPI(user.facebook_access_token)
  pages = api.fetch("me/accounts")
  for page in pages['data']:
    m = Page(
      parent=user.key,
      id=page['id'],
      access_token=page['access_token'],
      name=page['name'],
    )
    m.put()

    taskqueue.Queue('facebook').add(
      taskqueue.Task(
        url='/worker/fetch_page',
        params={
          'key': m.key.urlsafe(),
        }
      )
    )
开发者ID:studyindenmark,项目名称:clerkster,代码行数:22,代码来源:worker.py

示例13: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
    def post(self):
        current_user = users.get_current_user()

        if not current_user:
            return self.redirect('/')

        user = User.get_by_id(current_user.user_id())

        if not user:
            return self.redirect('/register')

        try:
            page = Page(parent=user.key)
            page.user = user.key
            page.url = self.request.get('url')
            page.name = self.request.get('name')
            page.put()

            self.redirect('/')
        except db.Error:
            self.redirect('/')
开发者ID:josemontesdeoca,项目名称:web-monitor,代码行数:23,代码来源:handlers.py

示例14: store_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
  def store_pages(self, route_handlers):
    """Stores information on each handler in the datastore and returns a list
    of routes for the Router.
    
    :param routes_handler:
        A list of FrameworkHandler subclasses which identify routes and 
        their meta data.
    :returns:
        A list of webapp2.Route instance.
    """
    memcache.delete('navigation_pages')
    routes = []
    new_key_set = set()
    for route_handler in route_handlers:
      # Checks if datastore entry exits and uses if it is.
      query = Page.query(Page.url == route_handler.url)
      datastore_list = query.fetch(1)
      if datastore_list:
        datastore_entity = datastore_list[0]
      else:
        datastore_entity = Page()

      datastore_entity.url = route_handler.url
      datastore_entity.page_title = route_handler.page_title
      datastore_entity.appear_in_navigation = route_handler.appear_in_navigation
      #TODO: Not write to the datastore if there are no changes to be made
      datastore_entity.put()
      new_key_set.add(datastore_entity.key)
      
      # Creates a route for each handler and adds it to the routes list
      routes.append(webapp2.Route(route_handler.url, route_handler))
      
    # The following removes old pages from the datastore
    old_key_set = set(Page.query().fetch(keys_only=True))
    ndb.delete_multi(list(old_key_set - new_key_set))
    
    return routes
开发者ID:RaspberryPiFi,项目名称:CloudCode,代码行数:39,代码来源:customframework.py

示例15: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import put [as 别名]
	def post(self, title):
		# check the user identity
		cookie_val = self.request.cookies.get('user_id')

		#check whether it is login user
		username = checkUser(cookie_val)	
		if username:

			content = self.request.get("content")

			if content and len(str.strip(str(content))):
				#save to Page

				page = Page(title=title,content=content)
				page.put()
				
				self.redirect("/"+title)
			else:
				error="the content must contain somthing.."
				self.render_front(username=username,title=title,error=error,content=content)
		else:
			#punish the stupid hacker	
			self.error("404")
			return 
开发者ID:johnzw,项目名称:MiniWiki,代码行数:26,代码来源:main.py


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