当前位置: 首页>>代码示例>>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;未经允许,请勿转载。