本文整理汇总了Python中models.WikiPage类的典型用法代码示例。如果您正苦于以下问题:Python WikiPage类的具体用法?Python WikiPage怎么用?Python WikiPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WikiPage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_logical_operations
def test_logical_operations(self):
self.assertEqual([{u'name': u'The Mind\'s I'}, {u'name': u'GEB'}],
WikiPage.wikiquery(u'"GEB" + "The Mind\'s I"'))
self.assertEqual({u'name': u'The Mind\'s I'},
WikiPage.wikiquery(u'schema:"Book" * author:"Douglas Hofstadter" * author:"Daniel Dennett"'))
self.assertEqual([{'name': u"The Mind's I"}, {'name': u'GEB'}],
WikiPage.wikiquery(u'schema:"Book" + author:"Douglas Hofstadter" * author:"Daniel Dennett"'))
开发者ID:namongk,项目名称:ecogwiki,代码行数:7,代码来源:test_wikiquery.py
示例2: get_changes
def get_changes(self, user, head):
restype = get_restype(self.request)
rendered = None
if restype == 'default':
if rendered is None:
pages = WikiPage.get_changes(user)
rendered = template(self.request, 'wiki_sp_changes.html',
{'pages': pages})
self.response.headers['Content-Type'] = 'text/html; charset=utf-8'
set_response_body(self.response, rendered, head)
elif restype == 'atom':
if rendered is None:
pages = WikiPage.get_changes(None, 3, include_body=True)
config = WikiPage.get_config()
host = self.request.host_url
url = "%s/sp.changes?_type=atom" % host
feed = AtomFeed(title="%s: changes" % config['service']['title'],
feed_url=url,
url="%s/" % host,
author=config['admin']['email'])
for page in pages:
feed.add(title=page.title,
content_type="html",
content=page.rendered_body,
author=page.modifier,
url='%s%s' % (host, page.absolute_url),
updated=page.updated_at)
rendered = feed.to_string()
self.response.headers['Content-Type'] = 'text/xml; charset=utf-8'
set_response_body(self.response, rendered, head)
else:
self.abort(400, 'Unknown type: %s' % restype)
开发者ID:namongk,项目名称:ecogwiki,代码行数:33,代码来源:views.py
示例3: wiki_page_edit
def wiki_page_edit(request, page_path, _page_obj=None):
page = _page_obj or WikiPage.get_object_by_path(page_path)
preview_action = request.POST and 'preview' in request.POST
if request.POST:
form = WikiPageForm(data=request.POST, initial={'author':request.user}, instance=page)
if form.is_valid():
page = form.save(commit=False)
if not preview_action:
pages = WikiPage.make_path(page_path, kwargs={'author':request.user})
if pages:
page.parent_page = pages[-1]
page.title = WikiPage.get_title_from_path(page_path)
print page_path
print page.title
page.author = request.user
page.save()
return redirect('wiki_page', page_path=page_path)
else:
form = WikiPageForm(initial={'author':request.user}, instance=page)
context = {}
context['page'] = page
context['page_path'] = page_path
context['form'] = form
context['preview_action'] = preview_action
return context
开发者ID:Apkawa,项目名称:django-wikinya,代码行数:27,代码来源:views.py
示例4: get_sp_index
def get_sp_index(self, user, head):
restype = self._get_restype()
if restype == "default":
pages = WikiPage.get_index(user)
page_group = groupby(pages, lambda p: title_grouper(p.title))
html = self._template("wiki_sp_index.html", {"page_group": page_group})
self.response.headers["Content-Type"] = "text/html; charset=utf-8"
self._set_response_body(html, head)
elif restype == "atom":
pages = WikiPage.get_index(None)
config = WikiPage.yaml_by_title(".config")
host = self.request.host_url
url = "%s/sp.index?_type=atom" % host
feed = AtomFeed(
title="%s: title index" % config["service"]["title"],
feed_url=url,
url="%s/" % host,
author=config["admin"]["email"],
)
for page in pages:
feed.add(
title=page.title,
content_type="html",
author=page.modifier,
url="%s%s" % (host, page.absolute_url),
updated=page.updated_at,
)
self.response.headers["Content-Type"] = "text/xml; charset=utf-8"
self._set_response_body(feed.to_string(), head)
else:
self.abort(400, "Unknown type: %s" % restype)
开发者ID:uastory,项目名称:ecogwiki,代码行数:31,代码来源:views.py
示例5: get_index
def get_index(self, user, head):
restype = get_restype(self.request)
if restype == 'default':
pages = WikiPage.get_index(user)
page_group = groupby(pages,
lambda p: title_grouper(p.title))
html = template(self.request, 'wiki_sp_index.html',
{'page_group': page_group})
self.response.headers['Content-Type'] = 'text/html; charset=utf-8'
set_response_body(self.response, html, head)
elif restype == 'atom':
pages = WikiPage.get_index(None)
config = WikiPage.get_config()
host = self.request.host_url
url = "%s/sp.index?_type=atom" % host
feed = AtomFeed(title="%s: title index" % config['service']['title'],
feed_url=url,
url="%s/" % host,
author=config['admin']['email'])
for page in pages:
feed.add(title=page.title,
content_type="html",
author=page.modifier,
url='%s%s' % (host, page.absolute_url),
updated=page.updated_at)
self.response.headers['Content-Type'] = 'text/xml; charset=utf-8'
set_response_body(self.response, feed.to_string(), head)
else:
self.abort(400, 'Unknown type: %s' % restype)
开发者ID:namongk,项目名称:ecogwiki,代码行数:29,代码来源:views.py
示例6: get
def get(self, path, head=False):
cache.create_prc()
query = WikiPage.path_to_title(path)
user = get_cur_user()
result = WikiPage.wikiquery(query, user)
view = self.request.GET.get('view', 'default')
restype = get_restype(self.request)
if restype == 'default' or restype == 'html':
if view == 'bodyonly':
html = template(self.request, 'bodyonly.html', {
'title': u'Search: %s ' % query,
'body': obj_to_html(result),
})
else:
html = template(self.request, 'wikiquery.html', {
'query': query,
'result': obj_to_html(result),
})
self.response.headers['Content-Type'] = 'text/html; charset=utf-8'
set_response_body(self.response, html, head)
elif restype == 'json':
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
set_response_body(self.response, json.dumps(result), head)
else:
self.abort(400, 'Unknown type: %s' % restype)
开发者ID:namongk,项目名称:ecogwiki,代码行数:25,代码来源:views.py
示例7: test_normal_links
def test_normal_links(self):
page_a = WikiPage.get_by_title(u"A")
page_a.update_content(u"[[B]]", 0)
page_b = WikiPage.get_by_title(u"B")
self.assertEqual([u"A"], page_b.data["inlinks"])
self.assertEqual([u"B"], page_a.data["outlinks"])
开发者ID:namongk,项目名称:ecogwiki,代码行数:7,代码来源:test_schema.py
示例8: test_no_links
def test_no_links(self):
a = WikiPage.get_by_title(u'A')
a.update_content(u'Hello', 0)
a = WikiPage.get_by_title(u'A')
self.assertEqual({}, a.inlinks)
self.assertEqual({}, a.outlinks)
开发者ID:namongk,项目名称:ecogwiki,代码行数:7,代码来源:test_models.py
示例9: test_no_links
def test_no_links(self):
a = WikiPage.get_by_title(u"A")
a.update_content(u"Hello", 0, "")
a = WikiPage.get_by_title(u"A")
self.assertEqual({}, a.inlinks)
self.assertEqual({}, a.outlinks)
开发者ID:uastory,项目名称:ecogwiki,代码行数:7,代码来源:test_models.py
示例10: test_delete_published_page
def test_delete_published_page(self):
self.login('[email protected]', 'a', is_admin=True)
WikiPage.get_by_title(u'Hello 2').delete(self.get_cur_user())
newer, older = WikiPage.get_posts_of(None, 20)
self.assertEqual(u'Hello 3', older.newer_title)
self.assertEqual(u'Hello 1', newer.older_title)
开发者ID:jangxyz,项目名称:ecogwiki,代码行数:7,代码来源:test_blog.py
示例11: _edit
def _edit(request, page):
# Have to do special stuff with handling the app home URN index
if page == None:
page = 'index'
# Check if user is signed in, if not, go back to the app index
name = signed_in(request)
if not name: return redirect('final_wiki', page='')
# Is this post?
if request.method == "POST":
# Grab post info
form = SubmitForm(request.POST)
content = form.data['content']
if form.is_valid():
# If this wikipage doesn't exist, create new and save
if not WikiPage.objects.filter(page_url=page).exists():
m = WikiPage(page_url=page)
m.save()
# If it does, grab it so we can update this page's history
else:
m = WikiPage.objects.get(page_url=page)
# Update this pages wikihistory!
n = WikiPageHistory(page=m, content=content)
n.save()
# Redirect back to the new page (handle index URN)
if page == 'index':
page = ''
return redirect('final_wiki', page=page)
# No post, so present the form to edit a wikipage
else:
# Create wikipage form
form = SubmitForm(request.POST)
# Show the values for the current page in the wikipage form
if WikiPage.objects.filter(page_url=page).exists():
i = WikiPage.objects.get(page_url=page)
j = return_wikipagehistory(i, request.GET.get('v'))
# If there is no page history, make sure the index (/) is referred to as (index)
if not j:
if page == "index":
page = ''
return redirect('final__edit', page=page)
# Where we pass the form content to the _edit view
content = j.content
else:
# Just pass blank content to the form, this is a new page
content = ""
# Pass along stuff and render
d=dict(content=content, page=page, name=name)
return render_to_response("7_final/edit.html", d, context_instance=RequestContext(request))
开发者ID:inheritancejon,项目名称:udacity253,代码行数:59,代码来源:views.py
示例12: test_update_rel
def test_update_rel(self):
self.update_page(u'[[1979]]', u'A')
self.update_page(u'.schema Person\n[[birthDate::1979]]', u'A')
page = WikiPage.get_by_title(u'A')
year = WikiPage.get_by_title(u'1979')
self.assertEqual({u'Person/birthDate': [u'1979']}, page.outlinks)
self.assertEqual({u'Person/birthDate': [u'A']}, year.inlinks)
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:8,代码来源:test_models.py
示例13: test_add_schema
def test_add_schema(self):
self.update_page(u'[[1979]]', u'A')
self.update_page(u'.schema Book\n[[1979]]', u'A')
page = WikiPage.get_by_title(u'A')
year = WikiPage.get_by_title(u'1979')
self.assertEqual({u'Book/relatedTo': [u'1979']}, page.outlinks)
self.assertEqual({u'Book/relatedTo': [u'A']}, year.inlinks)
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:8,代码来源:test_models.py
示例14: post
def post(self, page_name):
opts = json.loads(self.request.body)
page = WikiPage(title=page_name)
version = WikiPageVersion(text=opts.get('content', []))
version.save()
page.versions.append(version)
page.save()
self.set_status(201)
开发者ID:chrisseto,项目名称:osf-marked,代码行数:8,代码来源:handlers.py
示例15: test_specifying_attr_order
def test_specifying_attr_order(self):
result = WikiPage.wikiquery(u'schema:"Book" > author, datePublished+')
self.assertEqual(u'1979', result[0]['datePublished'].pvalue)
self.assertEqual(u'1982', result[1]['datePublished'].pvalue)
result = WikiPage.wikiquery(u'schema:"Book" > author, datePublished-')
self.assertEqual(u'1982', result[0]['datePublished'].pvalue)
self.assertEqual(u'1979', result[1]['datePublished'].pvalue)
开发者ID:0hoo,项目名称:ecogwiki,代码行数:8,代码来源:test_wikiquery.py
示例16: test_unpublish_newest
def test_unpublish_newest(self):
newest = WikiPage.get_by_title(u'Hello 3')
newest.update_content(u'Hello 3', 1, '')
newer, older = WikiPage.get_published_posts(None, 20)
self.assertEqual(u'Hello 2', older.newer_title)
self.assertEqual(u'Hello 1', newer.older_title)
开发者ID:cornchz,项目名称:ecogwiki,代码行数:8,代码来源:test_blog.py
示例17: test_first_publish
def test_first_publish(self):
self.update_page(u'Hello', u'Hello')
self.assertEqual(0, len(WikiPage.get_posts_of(None, 20)))
page = self.update_page(u'.pub\nHello', u'Hello')
self.assertIsNotNone(page.published_at)
self.assertIsNone(page.published_to)
self.assertEqual(1, len(WikiPage.get_posts_of(None, 20)))
开发者ID:jangxyz,项目名称:ecogwiki,代码行数:8,代码来源:test_blog.py
示例18: test_remove_schema
def test_remove_schema(self):
self.update_page(u'.schema Code\n[[1979]]', u'A')
self.update_page(u'[[1979]]', u'A')
page = WikiPage.get_by_title(u'A')
year = WikiPage.get_by_title(u'1979')
self.assertEqual({u'Article/relatedTo': [u'1979']}, page.outlinks)
self.assertEqual({u'Article/relatedTo': [u'A']}, year.inlinks)
开发者ID:Sunsoo,项目名称:ecogwiki,代码行数:8,代码来源:test_models.py
示例19: test_years_section
def test_years_section(self):
page = WikiPage.get_by_title(u"2")
ss = page.special_sections[u"years"]
self.assertEqual([u"2 BCE", u"1 BCE", u"1", u"2", u"3", u"4", u"5"], ss[u"years"])
page = WikiPage.get_by_title(u"2 BCE")
ss = page.special_sections[u"years"]
self.assertEqual([u"5 BCE", u"4 BCE", u"3 BCE", u"2 BCE", u"1 BCE", u"1", u"2"], ss[u"years"])
开发者ID:uastory,项目名称:ecogwiki,代码行数:8,代码来源:test_models.py
示例20: test_compare_yaml_and_embedded_data
def test_compare_yaml_and_embedded_data(self):
page1 = WikiPage.get_by_title(u'A')
page1.update_content(u'.schema Book\n #!yaml/schema\n datePublished: "1979-03-01"\n', 0)
page2 = WikiPage.get_by_title(u'B')
page2.update_content(u'.schema Book\n\n[[datePublished::1979-03-01]]', 0)
self.assertEqual(page1.data['datePublished'], page2.data['datePublished'])
self.assertEqual(page1.outlinks, page2.outlinks)
开发者ID:namongk,项目名称:ecogwiki,代码行数:8,代码来源:test_models.py
注:本文中的models.WikiPage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论