當前位置: 首頁>>代碼示例>>Python>>正文


Python Document.all方法代碼示例

本文整理匯總了Python中models.Document.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Document.all方法的具體用法?Python Document.all怎麽用?Python Document.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Document的用法示例。


在下文中一共展示了Document.all方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: viewDocs

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import all [as 別名]
def viewDocs(request):

  params = {}
  user = users.get_current_user()

  # Synchronise with Google Docs Feed
  if users.IsCurrentUserAdmin():
    authsub_url, session_token, client = check_auth(request, user)
    docs_url = 'http://docs.google.com/feeds/documents/private/full'

    import gdata.docs.service
    client = gdata.docs.service.DocsService()
    gdata.alt.appengine.run_on_appengine(client)

    getFeed(client, category='document')
    getFeed(client, category='spreadsheet')
    getFeed(client, category='presentation')
    getFeed(client, category='pdf')

  documents = Document.all()
  if not users.IsCurrentUserAdmin():
    documents.filter('status = ', 'Public')
  documents.order('-status')

  params['documents'] = documents
  return respond(request, 'list.html', params)
開發者ID:hollerith,項目名稱:schoogle,代碼行數:28,代碼來源:views.py

示例2: document_list

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import all [as 別名]
def document_list(request, page=1):
    """
    Displays document lists, 10 at a time.
    """
    cache_key = 'document_page:%s' % page
    cached_response = get_cached_response(request, cache_key)
    if cached_response:
        return cached_response
    else:
        # Pull the documents
        object_list = Document.all().filter(
                "is_published =", True
            ).order("-publication_date")
        # Cut it first 10
        paginator = Paginator(object_list, 10)
        try:
            page = paginator.page(page)
        except (EmptyPage, InvalidPage):
            raise Http404
        # Create the response
        context = {
            'headline': 'Latest Documents',
            'object_list': page.object_list,
            'page_number': page.number,
            'has_next': page.has_next(),
            'next_page_number': page.next_page_number(),
            'next_page_url': '/page/%s/' % (page.next_page_number())
        }
        response = direct_to_template(request, 'document_list.html', context)
        # Add it to the cache
        memcache.add(cache_key, response, 60)
        # Pass it back
        return response
開發者ID:datadesk,項目名稱:latimes-document-stacker,代碼行數:35,代碼來源:views.py

示例3: tag_page

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import all [as 別名]
def tag_page(request, tag, page):
    """
    Lists documents with a certain tag.
    """
    # Check if the page is cached
    cache_key = 'tag_page:%s-%s' % (tag, page)
    cached_response = get_cached_response(request, cache_key)
    if cached_response:
        return cached_response
    # Get the data
    tag = Tag.get_by_key_name(tag)
    if not tag:
        raise Http404
    object_list = Document.all().filter('tags =', tag.key()).filter("is_published =", True)
    paginator = Paginator(object_list, 10)
    # Limit it to thise page
    try:
        page = paginator.page(page)
    except (EmptyPage, InvalidPage):
        raise Http404
    # Create a response and pass it back
    context = {
        'headline': 'Documents tagged ‘%s’' % tag.title,
        'object_list': page.object_list,
        'page_number': page.number,
        'has_next': page.has_next(),
        'next_page_number': page.next_page_number(),
        'next_page_url': '/tag/%s/page/%s/' % (tag.title, page.next_page_number())
    }
    return direct_to_template(request, 'document_list.html', context)
開發者ID:datadesk,項目名稱:latimes-document-stacker,代碼行數:32,代碼來源:views.py

示例4: deleteDoc

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import all [as 別名]
def deleteDoc(request, key=None):
  params = {}
  document = db.get(key)
  document.delete()
  documents = Document.all()
  params['documents'] = documents

  return viewDocs(request)
開發者ID:hollerith,項目名稱:schoogle,代碼行數:10,代碼來源:views.py

示例5: sitemap

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import all [as 別名]
def sitemap(request):
    """
    A sitemap for Google.
    """
    document_list = Document.all().filter("is_published =", True).order("-publication_date")
    project_list = Project.all().filter("is_published =", True)
    context = {
        'document_list': document_list,
        'project_list': project_list,
    }
    return direct_to_template(request, 'sitemap.xml', context, mimetype='text/xml')
開發者ID:datadesk,項目名稱:latimes-document-stacker,代碼行數:13,代碼來源:views.py

示例6: publishDoc

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import all [as 別名]
def publishDoc(request, key=None):
  params = {}
  document = db.get(key)
  if document.status == 'Private':
    document.status = 'Public'
  else:
    document.status = 'Private'
  document.put()

  documents = Document.all()
  params['documents'] = documents

  return viewDocs(request)
開發者ID:hollerith,項目名稱:schoogle,代碼行數:15,代碼來源:views.py


注:本文中的models.Document.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。