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


Python generic.View類代碼示例

本文整理匯總了Python中django.views.generic.View的典型用法代碼示例。如果您正苦於以下問題:Python View類的具體用法?Python View怎麽用?Python View使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: __init__

    def __init__(self, **kwargs):
        """
        Sets up a context object for views to augment. Populates it with the top level
        articles from the DB.

        @todo look into RequestContext for a better method of doing this
        @todo look into memcache so the db isn't hit on every request
        """
        View.__init__(self, **kwargs)
開發者ID:rjlowes,項目名稱:codejockey,代碼行數:9,代碼來源:base.py

示例2: __init__

 def __init__(self, **kwargs):
     View.__init__(self, **kwargs)
     self.language = ''
     self.request = None
     self.params = {}
     self.responsesxml = etree.Element('REPONSES')
     self.responsexml = etree.SubElement(self.responsesxml, 'REPONSE')
     self.items = None
     self.item = None
     self.is_new = False
     self.has_changed = False
開發者ID:povtux,項目名稱:core,代碼行數:11,代碼來源:xferbasic.py

示例3: __init__

 def __init__(self, **kwargs):
     View.__init__(self, **kwargs)
     self.language = ''
     self.request = None
     self.params = {}
     self.responsejson = {}
     self.items = None
     self.item = None
     self.is_new = False
     self.has_changed = False
     self.format = 'JSON'
開發者ID:Lucterios2,項目名稱:core,代碼行數:11,代碼來源:xferbasic.py

示例4: __init__

    def __init__(self, **kwargs):
        View.__init__(self, **kwargs)

        # Allow this view to easily switch between feed formats.
        format = kwargs.get('format', self.format)
        try:
            self.feed_type = _FEED_FORMATS[format]
        except KeyError:
            raise ValueError("Unsupported feed format: {0}. Supported are: {1}".format(
                self.format, ', '.join(sorted(_FEED_FORMATS.iterkeys()))
            ))
開發者ID:nschlemm,項目名稱:django-fluent-blogs,代碼行數:11,代碼來源:feeds.py

示例5: dispatch

 def dispatch(self, request, *args, **kwargs):
     # Authentication
     if not users.get_current_user().email() in settings.AUTHORIZED_USER:
         if not 'localhost' == request.META['SERVER_NAME']:
             if not 0 == len(settings.AUTHORIZED_USER):
                 return HttpResponse(status=403)
     return View.dispatch(self, request, *args, **kwargs)
開發者ID:grapswiz,項目名稱:awikie,代碼行數:7,代碼來源:views.py

示例6: dispatch

 def dispatch(self, request, *args, **kwargs):
     if not self.has_permission(request, *args, **kwargs):
         if not request.user.is_authenticated():
             path = request.get_full_path()
             return HttpResponseRedirect("%s?next=%s" % (settings.LOGIN_URL,
                 path))
         else:
             return render_to_forbidden(request)
     return _View.dispatch(self, request, *args, **kwargs)
開發者ID:Shirk,項目名稱:OpenSlides,代碼行數:9,代碼來源:views.py

示例7: test_post_process_urls_adds_decorator

    def test_post_process_urls_adds_decorator(self):
        fake_decorator = mock.Mock()
        fake_decorator.return_value = 'fake_callback'

        application.get_url_decorator = mock.Mock()
        application.get_url_decorator.return_value = fake_decorator

        pattern = url('^$', View.as_view(), name='index')
        processed_patterns = application.post_process_urls([pattern])

        application.get_url_decorator.assert_called_once_with(pattern)
        self.assertEqual(processed_patterns[0].callback, 'fake_callback')
開發者ID:marangonico,項目名稱:django-oscar,代碼行數:12,代碼來源:test_application.py

示例8: setUp

    def setUp(self):
        self.user = UserFactory()

        self.authed_view = TemplateView.as_view(template_name='base.html')
        self.authed_view_kwargs = {'authed': True}
        self.anonymous_view = TemplateView.as_view(template_name='base.html')
        self.anonymous_view_kwargs = {'anonymous': True}
        self.other_anonymous_view = View.as_view()
        self.view_kwargs = {
            'authed_view': self.authed_view,
            'authed_view_kwargs': self.authed_view_kwargs,
            'anonymous_view': self.anonymous_view,
            'anonymous_view_kwargs': self.anonymous_view_kwargs}
開發者ID:epicbagel,項目名稱:django-libs,代碼行數:13,代碼來源:views_tests.py

示例9: assert_status

def assert_status(
    code: int,
    user: settings.AUTH_USER_MODEL,
    view: View,
    challenge: Challenge,
    rf: RequestFactory,
):
    request = rf.get("/rand")
    request.challenge = challenge

    if user is not None:
        request.user = user

    view = view.as_view()

    if code == 403:
        with pytest.raises(PermissionDenied):
            view(request)
        response = None
    else:
        response = view(request)
        assert response.status_code == code

    return request, response
開發者ID:comic,項目名稱:comic-django,代碼行數:24,代碼來源:utils.py

示例10: path

        views.InstrumentDetail.as_view(),
        name="instrument_detail",
    ),
    path(
        "stations/<int:station_id>/timeseries/<int:pk>/",
        views.TimeseriesDetail.as_view(),
        name="timeseries_detail",
    ),
    path("admin/", admin.site.urls),
    path("api/", include(enhydris_api_urls)),
    # For the following, see ticket #181
    path("timeseries/data/", views_old.timeseries_data, name="timeseries_data"),
]

# A view that does nothing, that will be used in some fake patterns below
_null_view = View.as_view()

# When a user registers, an email is sent, containing a link that the user has to click
# in order to confirm the email. In order to create that link, django-rest-auth uses
# reverse("account_confirm_email"). So we include that in the urlpatterns, although it's
# not actually being used and should not be served by Django. The web server should be
# configured to route that URL to the front-end, which should then POST to the
# verify-email API endpoint in order to perform the actual verification.
urlpatterns += [
    path("confirm-email/<str:key>/", _null_view, name="account_confirm_email")
]

# When a user registers, django-allauth runs reverse("account_email_verification_sent")
# in order to redirect to a page that says "We sent an email verification, click the
# link in that email". In our case, registration is done by POST to an API endpoint,
# which merely responds with "201". However, because something in django-allauth or in
開發者ID:openmeteo,項目名稱:enhydris,代碼行數:31,代碼來源:urls.py

示例11: patterns

"""
URLs for filebrowser in TinyMCE
"""
from django.conf.urls import url
from django.conf.urls import patterns
from django.views.generic import View

from zinnia_tinymce.views import RemoveFileView
from zinnia_tinymce.views import FileBrowserView
from zinnia_tinymce.views import FileBrowserCallBackView


urlpatterns = patterns(
    '',
    url(r'^$',
        View.as_view(),
        name='tinymce-filebrowser-dispatch'),
    url(r'^callback.js$',
        FileBrowserCallBackView.as_view(),
        name='tinymce-filebrowser-callback'),
    url(r'^(?P<file_type>\w+)/$',
        FileBrowserView.as_view(),
        name='tinymce-filebrowser'),
    url(r'^(?P<file_type>\w+)/remove/(?P<pk>\d+)/$',
        RemoveFileView.as_view(),
        name='tinymce-filebrowser-remove')
)
開發者ID:DOE-NEPA,項目名稱:zinnia-wysiwyg-tinymce,代碼行數:27,代碼來源:filebrowser.py

示例12: __init__

 def __init__(self, **kwargs):
     View.__init__(self, **kwargs)
     self.form = None
     self.form_values = None
     self.term = None
開發者ID:IRI-Research,項目名稱:jocondelab,代碼行數:5,代碼來源:back_office.py

示例13: patterns

from django.conf.urls import patterns, url
from django.views.generic import View


urlpatterns = patterns(
    '',
    url(r'^simple/action/$', View.as_view(), name='simpleAction'),
)
開發者ID:Anirudh58,項目名稱:django-mini-project,代碼行數:8,代碼來源:urls.py

示例14: get_extra_urls

 def get_extra_urls(self):
     return patterns('',
         url(r'^login/$',
             View.as_view(),
             name='login'),
     )
開發者ID:pculture,項目名稱:django-djam,代碼行數:6,代碼來源:test_base.py

示例15: dispatch

 def dispatch(self, request, *args, **kwargs):
     return View.dispatch(self, request, *args, **kwargs)
開發者ID:OpenLuna,項目名稱:luna-chatterbot,代碼行數:2,代碼來源:views.py


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