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

Python models.Page类代码示例

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

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



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

示例1: edit

def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == "POST":
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data["name"]
            page.content = form.cleaned_data["content"]

            page.save()
            return HttpResponseRedirect("../../%s/" % page.name)
    else:
        if page:
            form = PageForm(initial=page.__dict__)
        else:
            form = PageForm(initial={"name": name})

    return render_to_response(
        "wiki/edit.html",
        {
            "form": form,
            "admin": is_admin(request),
            "user": get_user(request),
            "navbar": Page.objects.get(name="NavBar"),
        },
    )
开发者ID:victorusachev,项目名称:djangy,代码行数:32,代码来源:views.py


示例2: processCmsRequest

def processCmsRequest(request, resource):
    if request.user.is_authenticated():
        loged = "<br><br>Logged in as " + request.user.username +\
                ". <a href='/admin/logout/'>Logout</a><br>"
    else:
        loged = "<br><br>Not logged. <a href='/admin/login/'>Login</a><br>"
    if request.method == 'GET':
        try:
            page = Page.objects.get(name=resource)
            return HttpResponse(page.page + loged)
        except Page.DoesNotExist:
            return HttpResponseNotFound("Page not found" + loged)
    elif request.method == 'PUT':
        if request.user.is_authenticated():
            try:
                newPage = Page.objects.get(name=resource)
                newPage.page = request.body
            except Page.DoesNotExist:
                newPage = Page(name = resource, page = request.body)
            newPage.save()
            return HttpResponse("Added to the list")
        else:
            return HttpResponse("Couldn't add to the list" + loged)
    else:
        return HttpResponse(status=403)
开发者ID:reysam93,项目名称:X-Serv-15.8-CmsUsersPut,代码行数:25,代码来源:views.py


示例3: addPage

def addPage(name, content):
    try:
        newPage = Page.objects.get(name=name)
        newPage.page = content
    except Page.DoesNotExist:
        newPage = Page(name = name, page = content)
    newPage.save()
开发者ID:reysam93,项目名称:X-Serv-CSS-Elaborado,代码行数:7,代码来源:views.py


示例4: get

  def get(self, name):
    """Handles the get requests for edit page of the wiki pages

    The user will get redirected to the SignupPage if authentication fails.

    If a version is specified in the url it retreives the corresponding version
    of the requested page. If the version doesn't exists, it redirects to the
    requested edit page without a version specified.

    If no version is specified the latest version of the page will be retreived
    to be displayed.

    If there is no version of the page in the datastore, the requested name will
    be transformed and used for Page.name.
    """
    self.restrictedArea()
    name = utils.checkPage(name)

    version = self.request.get('v')
    version = 0 if not version else int(version) 
    
    page = Page.getName(name, version)

    if not page and version:
      self.redirect('/_edit/%s' % name)
      return None

    if not page and not version:
      page = Page.createPage(name)

    params = { 'page': page }
    self.render(settings.TEMPLATE_FILENAME['edit'], **params)
开发者ID:vcelis,项目名称:cs253-wiki,代码行数:32,代码来源:wiki.py


示例5: make_request_context

def make_request_context(dic=None):
    from limited.utils import widgets
    from models import Page, Tag, User
    from viewutils import get_latest_comments

    if dic is None:
        dic = {}

    static_files = GroupedDict(find_static_files())

    dic.update((key, getattr(settings, key)) for key in ("BLOG_URL", "MEDIA_URL", "ADMINS", "USE_PYGMENTS"))
    dic.update(DEFAULT_CONTEXT_VARIABLES)
    dic.update(
        {
            "navigation_top": [HomePage()] + list(Page.filter(in_navigation=True)),
            "tags": Tag.objects.all().order_by("-name"),
            "latestcomments": get_latest_comments(),
            "popular_pages": Page.filter(popular=True),
            "WIDGETS": widgets.get_widgets(),
            "JS_FILES": static_files["js"],
            "CSS_FILES": static_files["css"],
            "limited": _internal.software_info(),
        }
    )

    if not "COPYRIGHT_YEARS" in dic:
        from datetime import datetime

        dic["COPYRIGHT_YEARS"] = [datetime.now().year]
    assert 0 < len(dic["COPYRIGHT_YEARS"]) < 3
    # two years at maximum

    return dic
开发者ID:jonashaag,项目名称:limited,代码行数:33,代码来源:__init__.py


示例6: edit

def edit(request, name):
    """Allows users to edit wiki pages."""
    try:
        page = Page.objects.get(name=name)
    except Page.DoesNotExist:
        page = None

    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.name = form.cleaned_data['name']
            page.content = form.cleaned_data['content']

            page.save()
            return redirect(view, name=page.name)
    else:
        if page:
            form = PageForm(initial=page.__dict__)
        else:
            form = PageForm(initial={'name': name})

    context = {
        'form': form,
    }

    return render_to_response('wiki/edit.html',
        RequestContext(request, context))
开发者ID:zouf,项目名称:AllSortz,代码行数:29,代码来源:views.py


示例7: post

    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,代码行数:27,代码来源:main.py


示例8: edit

def edit(request, slug):
    params = {"slug": slug}
    page = get_or_none(Page, slug=slug)

    text = page.current_revision.text if page and page.current_revision else ""
    form = EditForm(data=request.POST or None, initial={"text": text})

    if request.method == "POST" and form.is_valid():
        if not page:
            page = Page(title=unslugify(slug), slug=slug)
            page.save()
        form.save(page, request.user)
        return redirect(reverse("wiki-detail", kwargs={"slug": page.slug}))

    params["form"] = form
    if page:
        params["action"] = "Edit"
        params["title"] = page.title
        params["modified"] = page.modified_on
        params["action"] = "Edit"
    else:
        params["title"] = unslugify(slug)
        params["modified"] = "NULL"
        params["action"] = "Create"

    return render(request, "edit.html", params)
开发者ID:Corea,项目名称:algospot,代码行数:26,代码来源:views.py


示例9: wiki

def wiki(user_slug, wiki_slug):
    """ Renders a wiki's main page.
    -> user's slugified name; wiki's slugified title
    """
    try:
        user = User.get_by(name_slug=user_slug)
    except NoResultFound:
        flash("This user does not exist,<br />\
            and consequently, their wiki does not either.")
        return redirect(url_for('main'))
    try:
        wiki = user.wiki_by_slug(wiki_slug)
    except NoResultFound:
        if user_slug == g.user.name_slug:
            flash("This wiki does not exist.")
        else:
            flash("This wiki either is private or does not exist.")
        return redirect(url_for('main'))
    if request.method == 'POST':
        title = request.form['title']
        try:
            Page.get_by(title_slug=slugify(title))
        except NoResultFound:
            page = Page(wiki=wiki, title=title, title_slug=slugify(title), 
                content="<h1>%s</h1><p></p>" % title)
            models.session.commit()
        return redirect(url_for('wiki_page', user_slug=user.name_slug, 
            wiki_slug=wiki.title_slug, page_slug=slugify(title)))
    else:
        page = wiki.page_by_slug(wiki_slug)
    if wiki.permission_to_view(g.user):
        return render_template('page.html', user=user, wiki=wiki, page=page)
    else:
        flash("This wiki either is private or doesn't exist.")
        return redirect(url_for('main'))
开发者ID:aostrega,项目名称:piki,代码行数:35,代码来源:piki.py


示例10: contentapp

def contentapp(request,resourceName):
	response = "<h1> WELLCOME TO THE JUNGLE! </h1>"
	if request.method == "GET":
		try:
			info = Page.objects.get(name=resourceName)
			return HttpResponse(response + info.contenido)
		except Page.DoesNotExist:
			response += '<body> Valor no encontrado, definalo </body>'
			form = "<form action='' method='POST'>\n"
			form += "Nombre: <input type='text' name='name' value='" + resourceName + "'><br>\n"
			form += "Contenido: <input type='text' name='contenido'><br>\n"
			form += "<input type='submit' value='enviar'>\n"
			form += "</form>\n"
			response += form
			return HttpResponse(response)
	elif request.method == "POST":
		response += '<body> POST </body>' 
		newPage = Page(name=request.POST['name'], contenido=request.POST['contenido'])
		newPage.save()
		response += "Nombre: " + request.POST['name'] 
		response += ", Contenido: " + request.POST['contenido']
		return HttpResponse(response)
	else:
		response += '<body> No way </body>'
		return HttpResponse(response)
开发者ID:alexeal90,项目名称:X-Serv-15.6-Django-CMS_PUT,代码行数:25,代码来源:views.py


示例11: create_page

def create_page(db, page):
    new_data = Page()
    new_data.title = unicode(page['title'])
    new_data.content = unicode(page["content"])
    new_data.css = unicode(page['css'])
    new_data.book_id = int(page["book_id"])
    db.session.add(new_data)
开发者ID:Nauja,项目名称:ProjetLivre,代码行数:7,代码来源:db.py


示例12: get

	def get(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:
			#check whether the request has version para in it
			page=None
			version = self.request.get("v")

			if version:
				if version.isdigit():
					page = Page.get_by_id(int(version))
					if page:
						page=[page]
					else:
						self.error("404")
						return
				else:
					self.error("404")
					return
			# check whether the page has been created
			else:
				query = Page.fetchPages(title)
				page = query.fetch(1)

			if page:
				self.render_front(username=username,title=title,content=page[0].content)
			else:	
				self.render_front(username=username,title=title)
		else:
			self.redirect("/")
开发者ID:johnzw,项目名称:MiniWiki,代码行数:34,代码来源:main.py


示例13: get_object

    def get_object(self, request, region='', slug=''):
        self.setup_region(region)

        obj = Page(slug=slugify(slug), region=self.region)
        obj.title = obj.versions.most_recent().name
        obj.page = obj
        return obj
开发者ID:lowiki-org,项目名称:localwiki-backend-server,代码行数:7,代码来源:feeds.py


示例14: create_default_page

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,代码行数:7,代码来源:main.py


示例15: index

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,代码行数:27,代码来源:views.py


示例16: testBlogPaginate

    def testBlogPaginate(self):
        """Test view and template of a paginated blog
        Must have :
            - "Previous" link
            - "Next" link
            - Antichronological order

        """
        # Populate blog with temporary content
        temp = []
        for i in range(30):
            a = Page(title="temp_%s" % i, slug="temp-%s" % i, parent=self.blog21, folder_type=0, publish_state=Page.PUBLISHED )
            a.save()
            temp += [a]
        # Test Page 1
        response = self.client.get(urlblog('categ_2-fr/blog_21-fr', 1))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, temp[29].get_title())
        self.assertContains(response, urlblog('categ_2-fr/blog_21-fr', 2)) # Previous link
        self.assertNotContains(response, temp[1].get_title())
        # Test page 3
        response = self.client.get(urlblog('categ_2-fr/blog_21-fr', 3))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, urlblog('categ_2-fr/blog_21-fr', 2)) # Previous link
        self.assertContains(response, urlblog('categ_2-fr/blog_21-fr', 4)) # Next Link
        self.assertNotContains(response, temp[29].get_title())
        self.assertContains(response, temp[19].get_title())
开发者ID:bearstech,项目名称:OursID,代码行数:27,代码来源:tests.py


示例17: test_page_app_name_after_save

 def test_page_app_name_after_save(self):
     p = Page()
     p.save()
     self.assertEqual(p.app_model, 'pages.Page',
                      'Value for app_model is not correct after save.')
     self.assertEqual(p.get_app_model(), 'pages.Page',
                      'Value for get_app_model() is not correct after save.')
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:7,代码来源:tests.py


示例18: css

def css(page_key):
    preview = ('preview' in request.args) and (request.args.get('preview') != '0')
    pretty = ('pretty' in request.args) and (request.args.get('pretty') != '0')

    if not preview and not pretty:
        count_view('css:all')
        if request.referrer:
            count_view('css:page:%s:%s' % (urlparse(request.referrer).netloc, page_key))
        etag = memcache.get(page_key + '-css-etag')
        if etag and request.headers.get('If-None-Match', '') == etag:
            return 'Not Modified', 304
        css = memcache.get(page_key + '-css')
        if not css or not etag:
            page = Page.get_or_404(page_key)
            css = page.compressed_css(False)
            etag = _etag(css)
            expires = 24 * 60 * 60
            memcache.set(page_key + '-css-etag', etag, time=expires)
            memcache.set(page_key + '-css', css, time=expires)
        return _send_file(css, 'text/css', etag)
    else:
        page = Page.get_or_404(page_key)
        if pretty:
            css = page.uncompressed_css(preview)
        else:
            css = page.compressed_css(preview)
        return _send_file(css, 'text/css')
开发者ID:1ncnspcuous,项目名称:WebPutty,代码行数:27,代码来源:views.py


示例19: test_page_content_ptr_app_name

 def test_page_content_ptr_app_name(self):
     p = Page()
     p.save()
     c = p.content_ptr
     self.assertEqual(c.app_model, 'pages.Page',
                      'Value for content.app_model is not correct.')
     self.assertEqual(c.get_app_model(), 'pages.Page',
                      'Value for get_app_model() is not correct after save.')
开发者ID:pombredanne,项目名称:django-dogwood,代码行数:8,代码来源:tests.py


示例20: updatePageDB

def updatePageDB(title):
    current_page = Page.query.filter_by(name=title).first()
    if current_page is None:
        current_page = Page(title)
    else:
        current_page.visitPage()
    db.session.add(current_page)
    db.session.commit()
开发者ID:olivergoodman,项目名称:app-blueprint,代码行数:8,代码来源:app.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.PageOperationMixin类代码示例发布时间:2022-05-27
下一篇:
Python models.Order类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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