示例#1
0
 def process_view(self, request, view_func, view_args, view_kwargs):
     if getattr(view_func, '_non_atomic_gets', False):
         if request.method.lower() == 'get':
             transaction.non_atomic_requests(view_func)
         else:
             view_func._non_atomic_requests = set()
     return None
示例#2
0
 def process_view(self, request, view_func, view_args, view_kwargs):
     if getattr(view_func, '_non_atomic_gets', False):
         if request.method.lower() == 'get':
             transaction.non_atomic_requests(view_func)
         else:
             view_func._non_atomic_requests = set()
     return None
示例#3
0
 def as_view(cls, **initkwargs):
     """
     Don't run (async) request for transition atomically. When job is
     scheduled to worker, transaction has to be already commited, to allow
     worker to fetch Job from database.
     """
     return non_atomic_requests(super().as_view(**initkwargs))
示例#4
0
def non_atomic_when_eager(view_func):
    """
    Decorator which disables atomic requests for a view/dispatch function when celery is running in eager mode
    """
    if getattr(settings, 'CELERY_ALWAYS_EAGER', False):
        return transaction.non_atomic_requests(view_func)
    else:
        return view_func
示例#5
0
def non_atomic_when_eager(view_func):
    """
    Decorator which disables atomic requests for a view/dispatch function when celery is running in eager mode
    """
    if getattr(settings, 'CELERY_ALWAYS_EAGER', False):
        return transaction.non_atomic_requests(view_func)
    else:
        return view_func
示例#6
0
    def _urls_for_flow(self,
                       flow_namespace,
                       flow_component,
                       flow_position=None):

        urlpatterns = []

        if flow_position is None:
            flow_position = PossibleFlowPosition(self.app_namespace,
                                                 flow_namespace,
                                                 [flow_component])
        else:
            flow_position = PossibleFlowPosition(
                self.app_namespace, flow_namespace,
                flow_position.flow_component_classes + [flow_component])

        if hasattr(flow_component, 'urls'):
            flow_urls = flow_component.urls
        else:
            flow_urls = [flow_component.url]

        if issubclass(flow_component, Scaffold) and hasattr(
                flow_component, 'action_set'):
            for child in flow_component.action_set:
                for u in flow_urls:
                    urlpatterns += patterns(
                        '',
                        url(
                            u,
                            include(
                                self._urls_for_flow(flow_namespace, child,
                                                    flow_position))))

        elif issubclass(flow_component, Action):
            name = flow_position.get_url_name(include_app_namespace=False)
            view = self._view(flow_position)
            # If flow component class has a non_atomic_requests class
            # attribute set to True, then decorate the view with
            # django.db.transaction.non_atomic_requests
            non_atomic_requests = getattr(flow_component,
                                          'non_atomic_requests', None)
            if non_atomic_requests:
                view = transaction.non_atomic_requests(view)
            for u in flow_urls:
                urlpatterns += patterns('', url(u, view, name=name))

        else:
            raise TypeError(str(flow_component))

        return urlpatterns
示例#7
0
 def as_view(cls, actions=None, **initkwargs):
     view = super(DiscoveryItemViewSet, cls).as_view(actions=actions,
                                                     **initkwargs)
     return non_atomic_requests(view)
示例#8
0
 def as_view(cls, **kwargs):
     view = super(AddonFeaturedView, cls).as_view(**kwargs)
     return non_atomic_requests(view)
示例#9
0
                       url(r'^/log/$', WebHookEventListView.as_view(), name='api.log'),
                       url(r'^/log/(?P<pk>\d+)/$', WebHookEventReadView.as_view(), name='api.log_read'),

                       url(r'^/explorer/$', ApiExplorerView.as_view(), name='api.explorer'),

                       url(r'^/webhook/$', WebHookView.as_view(), name='api.webhook'),
                       url(r'^/webhook/simulator/$', WebHookSimulatorView.as_view(), name='api.webhook_simulator'),
                       url(r'^/webhook/tunnel/$', login_required(csrf_protect(WebHookTunnelView.as_view())), name='api.webhook_tunnel'),

                       url(r'^/broadcasts$', BroadcastsEndpoint.as_view(), name='api.broadcasts'),
                       url(r'^/messages$', MessagesEndpoint.as_view(), name='api.messages'),
                       url(r'^/sms$', MessagesEndpoint.as_view(), name='api.sms'),  # deprecated
                       url(r'^/labels$', LabelsEndpoint.as_view(), name='api.labels'),
                       url(r'^/flows$', FlowEndpoint.as_view(), name='api.flows'),
                       url(r'^/results', FlowResultsEndpoint.as_view(), name='api.results'),
                       url(r'^/runs$', non_atomic_requests(FlowRunEndpoint.as_view()), name='api.runs'),
                       url(r'^/calls$', Calls.as_view(), name='api.calls'),
                       url(r'^/contacts$', Contacts.as_view(), name='api.contacts'),
                       url(r'^/groups$', Groups.as_view(), name='api.contactgroups'),
                       url(r'^/fields$', FieldsEndpoint.as_view(), name='api.contactfields'),
                       url(r'^/relayers$', Channels.as_view(), name='api.channels'),
                       url(r'^/campaigns$', CampaignEndpoint.as_view(), name='api.campaigns'),
                       url(r'^/events$', CampaignEventEndpoint.as_view(), name='api.campaignevents'),
                       url(r'^/boundaries$', BoundaryEndpoint.as_view(), name='api.boundaries'),
                       )

# Format suffixes
urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'xml', 'api'])


示例#10
0
from django.conf.urls import url
from django.db.transaction import non_atomic_requests
from django.views.generic.base import TemplateView

from registration.backends.default.views import ActivationView
from registration.backends.default.views import RegistrationView


urlpatterns = patterns('',
                       url(r'^activate/complete/$',
                           TemplateView.as_view(template_name='registration/activation_complete.html'),
                           name='registration_activation_complete'),
                       # Activation keys get matched by \w+ instead of the more specific
                       # [a-fA-F0-9]{40} because a bad activation key should still get to the view;
                       # that way it can return a sensible "invalid key" message instead of a
                       # confusing 404.
                       url(r'^activate/(?P<activation_key>\w+)/$',
                           ActivationView.as_view(),
                           name='registration_activate'),
                       url(r'^register/$',
                           non_atomic_requests()(RegistrationView.as_view()),
                           name='registration_register'),
                       url(r'^register/complete/$',
                           TemplateView.as_view(template_name='registration/registration_complete.html'),
                           name='registration_complete'),
                       url(r'^register/closed/$',
                           TemplateView.as_view(template_name='registration/registration_closed.html'),
                           name='registration_disallowed'),
                       (r'', include('registration.auth_urls')),
                       )
示例#11
0
    url(r'^users/*', include('edx_solutions_api_integration.users.urls')),
    url(r'^groups/*', include('edx_solutions_api_integration.groups.urls')),
    url(r'^sessions/*',
        include('edx_solutions_api_integration.sessions.urls')),
    url(r'^courses/', include('edx_solutions_api_integration.courses.urls')),
    url(r'^organizations/*', include('edx_solutions_organizations.urls')),
    url(r'^mobile/v1/',
        include('edx_solutions_api_integration.mobile_api.urls')),
    url(r'^imports/*', include('edx_solutions_api_integration.imports.urls')),
    url(r'^courses_metadata/', include('course_metadata.urls')),
    # we have to explicitly define url for workgroup users detail view
    # to wrap it around non_atomic_requests decorator
    url(r'^workgroups/(?P<pk>\d+)/users/?$',
        transaction.non_atomic_requests(
            project_views.WorkgroupsViewSet.as_view({
                'get': 'users',
                'post': 'users',
                'delete': 'users',
            })),
        name='workgroup-users-detail'),
)

server_api_router = DefaultRouter()
server_api_router.register(r'organizations',
                           organization_views.OrganizationsViewSet)
server_api_router.register(r'projects', project_views.ProjectsViewSet)
server_api_router.register(r'workgroups', project_views.WorkgroupsViewSet)
server_api_router.register(r'submissions',
                           project_views.WorkgroupSubmissionsViewSet)
server_api_router.register(r'workgroup_reviews',
                           project_views.WorkgroupReviewsViewSet)
server_api_router.register(r'submission_reviews',
示例#12
0
 def as_view(cls, **kwargs):
     # Make all search views non_atomic: they should not need the db, or
     # at least they should not need to make db writes, so they don't need
     # to be wrapped in transactions.
     view = super(BaseFeedESView, cls).as_view(**kwargs)
     return non_atomic_requests(view)
示例#13
0
 def as_view(cls, actions=None, **initkwargs):
     view = super().as_view(actions=actions, **initkwargs)
     return non_atomic_requests(view)
示例#14
0
# coding:utf-8
#

from django.urls import path, include
from django.db.transaction import non_atomic_requests

from .. import views
from users import views as users_view

app_name = 'authentication'

urlpatterns = [
    # login
    path('login/', non_atomic_requests(views.UserLoginView.as_view()), name='login'),
    path('login/otp/', views.UserLoginOtpView.as_view(), name='login-otp'),
    path('login/wait-confirm/', views.UserLoginWaitConfirmView.as_view(), name='login-wait-confirm'),
    path('login/guard/', views.UserLoginGuardView.as_view(), name='login-guard'),
    path('logout/', views.UserLogoutView.as_view(), name='logout'),

    # 原来在users中的
    path('password/forgot/', users_view.UserForgotPasswordView.as_view(), name='forgot-password'),
    path('password/reset/', users_view.UserResetPasswordView.as_view(), name='reset-password'),
    path('password/verify/', users_view.UserVerifyPasswordView.as_view(), name='user-verify-password'),

    path('wecom/bind/success-flash-msg/', views.FlashWeComBindSucceedMsgView.as_view(), name='wecom-bind-success-flash-msg'),
    path('wecom/bind/failed-flash-msg/', views.FlashWeComBindFailedMsgView.as_view(), name='wecom-bind-failed-flash-msg'),
    path('wecom/bind/start/', views.WeComEnableStartView.as_view(), name='wecom-bind-start'),
    path('wecom/qr/bind/', views.WeComQRBindView.as_view(), name='wecom-qr-bind'),
    path('wecom/qr/login/', views.WeComQRLoginView.as_view(), name='wecom-qr-login'),
    path('wecom/qr/bind/<uuid:user_id>/callback/', views.WeComQRBindCallbackView.as_view(), name='wecom-qr-bind-callback'),
    path('wecom/qr/login/callback/', views.WeComQRLoginCallbackView.as_view(), name='wecom-qr-login-callback'),
示例#15
0
 def as_view(cls, **initkwargs):
     """The API is read-only so we can turn off atomic requests."""
     return non_atomic_requests(
         super(ScannerResultView, cls).as_view(**initkwargs))
示例#16
0
 def as_view(cls, **initkwargs):
     """The API is read-only so we can turn off atomic requests."""
     return non_atomic_requests(
         super(CompatOverrideView, cls).as_view(**initkwargs))
示例#17
0
         api.NodeChildrenAsTreeApi.as_view(),
         name='node-children-tree'),
    path('nodes/<uuid:pk>/children/',
         api.NodeChildrenApi.as_view(),
         name='node-children'),
    path('nodes/children/',
         api.NodeChildrenApi.as_view(),
         name='node-children-2'),
    path('nodes/<uuid:pk>/children/add/',
         api.NodeAddChildrenApi.as_view(),
         name='node-add-children'),
    path('nodes/<uuid:pk>/assets/',
         api.NodeAssetsApi.as_view(),
         name='node-assets'),
    path('nodes/<uuid:pk>/assets/add/',
         non_atomic_requests(api.NodeAddAssetsApi.as_view()),
         name='node-add-assets'),
    path('nodes/<uuid:pk>/assets/replace/',
         non_atomic_requests(api.MoveAssetsToNodeApi.as_view()),
         name='node-replace-assets'),
    path('nodes/<uuid:pk>/assets/remove/',
         non_atomic_requests(api.NodeRemoveAssetsApi.as_view()),
         name='node-remove-assets'),
    path('nodes/<uuid:pk>/tasks/',
         api.NodeTaskCreateApi.as_view(),
         name='node-task-create'),
    path('gateways/<uuid:pk>/test-connective/',
         api.GatewayTestConnectionApi.as_view(),
         name='test-gateway-connective'),
]
示例#18
0
 def as_view(cls, **initkwargs):
     """The API is read-only so we can turn off atomic requests."""
     return non_atomic_requests(
         super(LanguageToolsView, cls).as_view(**initkwargs))
示例#19
0
 def as_view(cls, **kwargs):
     view = super(StaticCategoryView, cls).as_view(**kwargs)
     return non_atomic_requests(view)
示例#20
0
# coding:utf-8
#

from django.urls import path, include
from django.db.transaction import non_atomic_requests

from .. import views
from users import views as users_view

app_name = 'authentication'

urlpatterns = [
    # login
    path('login/',
         non_atomic_requests(views.UserLoginView.as_view()),
         name='login'),
    path('login/mfa/', views.UserLoginMFAView.as_view(), name='login-mfa'),
    path('login/wait-confirm/',
         views.UserLoginWaitConfirmView.as_view(),
         name='login-wait-confirm'),
    path('login/guard/',
         views.UserLoginGuardView.as_view(),
         name='login-guard'),
    path('logout/', views.UserLogoutView.as_view(), name='logout'),

    # 原来在users中的
    path('password/forgot/',
         users_view.UserForgotPasswordView.as_view(),
         name='forgot-password'),
    path('password/reset/',
         users_view.UserResetPasswordView.as_view(),
示例#21
0
                                 xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                                 xmlns:eo="https://www.entrouvert.com/">
                               <eo:next_url>%s</eo:next_url>
                            </samlp:Extensions>''' % eo_next_url)
            self.set_next_url(next_url)
            login.buildAuthnRequestMsg()
        except lasso.Error as e:
            return HttpResponseBadRequest(
                'error initializing the authentication request: %r' % e)
        self.log.debug('sending authn request %r', authn_request.dump())
        self.log.debug('to url %r', login.msgUrl)
        return HttpResponseRedirect(login.msgUrl)


# we need fine control of transactions to prevent double user creations
login = transaction.non_atomic_requests(csrf_exempt(LoginView.as_view()))


class LogoutView(ProfileMixin, LogMixin, View):
    def get(self, request):
        if 'SAMLRequest' in request.GET:
            return self.idp_logout(request)
        elif 'SAMLResponse' in request.GET:
            return self.sp_logout_response(request)
        else:
            return self.sp_logout_request(request)

    def idp_logout(self, request):
        '''Handle logout request emitted by the IdP'''
        self.profile = logout = utils.create_logout(request)
        try:
示例#22
0
 def as_view(cls, **initkwargs):
     return transaction.non_atomic_requests()(super(cls, cls).as_view(**initkwargs))
示例#23
0
 def as_view(cls, *args, **initkwargs):
     view = super().as_view(*args, **initkwargs)
     return non_atomic_requests(view)
示例#24
0
 def as_view(cls, **kwargs):
     view = super(AddonSearchView, cls).as_view(**kwargs)
     return non_atomic_requests(view)
示例#25
0
 def as_view(cls, **initkwargs):
     """The API is read-only so we can turn off atomic requests."""
     return non_atomic_requests(
         super(CompatOverrideView, cls).as_view(**initkwargs))
示例#26
0
 def as_view(cls, **initkwargs):
     """The API is read-only so we can turn off atomic requests."""
     return non_atomic_requests(
         super(LanguageToolsView, cls).as_view(**initkwargs))
示例#27
0
 def as_view(cls, **kwargs):
     # Make all search views non_atomic: they should not need the db, or
     # at least they should not need to make db writes, so they don't need
     # to be wrapped in transactions.
     view = super(SearchView, cls).as_view(**kwargs)
     return non_atomic_requests(view)
示例#28
0
文件: mixins.py 项目: tapiau/CivilHub
 def as_view(cls, **initkwargs):
     view = super(AtomicFreeTransactionMixin, cls).as_view(**initkwargs)
     return non_atomic_requests(view)
示例#29
0
        WebHookSimulatorView.as_view(),
        name='api.webhook_simulator'),
    url(r'^/webhook/tunnel/$',
        login_required(csrf_protect(WebHookTunnelView.as_view())),
        name='api.webhook_tunnel'),
    url(r'^/broadcasts$', BroadcastsEndpoint.as_view(), name='api.broadcasts'),
    url(r'^/messages$', MessagesEndpoint.as_view(), name='api.messages'),
    url(r'^/message_actions$',
        MessagesBulkActionEndpoint.as_view(),
        name='api.message_actions'),
    url(r'^/sms$', MessagesEndpoint.as_view(), name='api.sms'),  # deprecated
    url(r'^/labels$', LabelsEndpoint.as_view(), name='api.labels'),
    url(r'^/flows$', FlowEndpoint.as_view(), name='api.flows'),
    url(r'^/results', FlowResultsEndpoint.as_view(), name='api.results'),
    url(r'^/runs$',
        non_atomic_requests(FlowRunEndpoint.as_view()),
        name='api.runs'),
    url(r'^/calls$', Calls.as_view(), name='api.calls'),
    url(r'^/contacts$', Contacts.as_view(), name='api.contacts'),
    url(r'^/groups$', Groups.as_view(), name='api.contactgroups'),
    url(r'^/fields$', FieldsEndpoint.as_view(), name='api.contactfields'),
    url(r'^/relayers$', Channels.as_view(), name='api.channels'),
    url(r'^/campaigns$', CampaignEndpoint.as_view(), name='api.campaigns'),
    url(r'^/events$',
        CampaignEventEndpoint.as_view(),
        name='api.campaignevents'),
    url(r'^/boundaries$', BoundaryEndpoint.as_view(), name='api.boundaries'),
    url(r'^/assets$', AssetEndpoint.as_view(), name='api.assets'))

# Format suffixes
urlpatterns = format_suffix_patterns(urlpatterns,
示例#30
0
    path('admin-users/<uuid:pk>/connective/', api.AdminUserTestConnectiveApi.as_view(), name='admin-user-connective'),
    path('admin-users/<uuid:pk>/assets/', api.AdminUserAssetsListView.as_view(), name='admin-user-assets'),

    path('system-users/<uuid:pk>/auth-info/', api.SystemUserAuthInfoApi.as_view(), name='system-user-auth-info'),
    path('system-users/<uuid:pk>/assets/', api.SystemUserAssetsListView.as_view(), name='system-user-assets'),
    path('system-users/<uuid:pk>/assets/<uuid:aid>/auth-info/', api.SystemUserAssetAuthInfoApi.as_view(), name='system-user-asset-auth-info'),
    path('system-users/<uuid:pk>/tasks/', api.SystemUserTaskApi.as_view(), name='system-user-task-create'),
    path('system-users/<uuid:pk>/cmd-filter-rules/', api.SystemUserCommandFilterRuleListApi.as_view(), name='system-user-cmd-filter-rule-list'),

    path('nodes/tree/', api.NodeListAsTreeApi.as_view(), name='node-tree'),
    path('nodes/children/tree/', api.NodeChildrenAsTreeApi.as_view(), name='node-children-tree'),
    path('nodes/<uuid:pk>/children/', api.NodeChildrenApi.as_view(), name='node-children'),
    path('nodes/children/', api.NodeChildrenApi.as_view(), name='node-children-2'),
    path('nodes/<uuid:pk>/children/add/', api.NodeAddChildrenApi.as_view(), name='node-add-children'),
    path('nodes/<uuid:pk>/assets/', api.NodeAssetsApi.as_view(), name='node-assets'),
    path('nodes/<uuid:pk>/assets/add/', non_atomic_requests(api.NodeAddAssetsApi.as_view()), name='node-add-assets'),
    path('nodes/<uuid:pk>/assets/replace/', non_atomic_requests(api.MoveAssetsToNodeApi.as_view()), name='node-replace-assets'),
    path('nodes/<uuid:pk>/assets/remove/', non_atomic_requests(api.NodeRemoveAssetsApi.as_view()), name='node-remove-assets'),
    path('nodes/<uuid:pk>/tasks/', api.NodeTaskCreateApi.as_view(), name='node-task-create'),

    path('gateways/<uuid:pk>/test-connective/', api.GatewayTestConnectionApi.as_view(), name='test-gateway-connective'),

]

old_version_urlpatterns = [
    re_path('(?P<resource>admin-user|system-user|domain|gateway|cmd-filter|asset-user)/.*', capi.redirect_plural_name_api)
]

urlpatterns += router.urls + cmd_filter_router.urls + old_version_urlpatterns

示例#31
0
 def as_view(cls, **kwargs):
     view = super(StaticCategoryView, cls).as_view(**kwargs)
     return non_atomic_requests(view)
示例#32
0
from django.db import transaction
from edx_solutions_api_integration.users import views as users_views
from rest_framework.urlpatterns import format_suffix_patterns

COURSE_ID_PATTERN = settings.COURSE_ID_PATTERN

urlpatterns = [
    url(r'^metrics/cities/$',
        users_views.UsersMetricsCitiesList.as_view(),
        name='apimgr-users-metrics-cities-list'),
    url(r'^(?P<user_id>[a-zA-Z0-9]+)/courses/grades$',
        users_views.UsersCoursesGradesList.as_view(),
        name='users-courses-grades-list'),
    url(r'^(?P<user_id>[a-zA-Z0-9]+)/courses/{}/grades$'.format(
        COURSE_ID_PATTERN),
        transaction.non_atomic_requests(
            users_views.UsersCoursesGradesDetail.as_view()),
        name='users-courses-grades-detail'),
    url(r'^(?P<user_id>[a-zA-Z0-9]+)/courses/{}/metrics/social/$'.format(
        COURSE_ID_PATTERN),
        users_views.UsersSocialMetrics.as_view(),
        name='users-social-metrics'),
    url(r'^(?P<user_id>[a-zA-Z0-9]+)/courses/{}$'.format(COURSE_ID_PATTERN),
        users_views.UsersCoursesDetail.as_view(),
        name='users-courses-detail'),
    url(r'^(?P<user_id>[a-zA-Z0-9]+)/courses/*$',
        transaction.non_atomic_requests(
            users_views.UsersCoursesList.as_view()),
        name='users-courses-list'),
    url(r'^(?P<user_id>[a-zA-Z0-9]+)/groups/*$',
        users_views.UsersGroupsList.as_view(),
        name='users-groups-list'),
示例#33
0
 def as_view(cls, **initkwargs):
     return non_atomic_requests(super().as_view(**initkwargs))
示例#34
0
 def as_view(cls, **initkwargs):
     view = super(BaseAPIView, cls).as_view(**initkwargs)
     return transaction.non_atomic_requests(view)