本文整理汇总了Python中tastypie.utils.trailing_slash函数的典型用法代码示例。如果您正苦于以下问题:Python trailing_slash函数的具体用法?Python trailing_slash怎么用?Python trailing_slash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trailing_slash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepend_urls
def prepend_urls(self):
return [
url(r"(?P<resource_name>%s)/post%s$"%(self._meta.resource_name,trailing_slash()),self.wrap_view('post_article'),name="api_post_article"),
url(r"(?P<resource_name>%s)/comment%s$"%(self._meta.resource_name,trailing_slash()),self.wrap_view('comment_article'),name="api_comment_article"),
url(r"(?P<resource_name>%s)/like%s$"%(self._meta.resource_name,trailing_slash()),self.wrap_view('like_article'),name="api_like_article"),
url(r"(?P<resource_name>%s)/list%s$"%(self._meta.resource_name,trailing_slash()),self.wrap_view('list_article'),name="api_list_article"),
]
示例2: base_urls
def base_urls(self):
return [
url(r"^" + self.parent_resource_name + "/(?P<pk>\w[\w-]*)/(?P<resource_name>%s)%s$" %
(self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_list'), name="api_dispatch_list"),
url(r"^" + self.parent_resource_name + "/(?P<pk>\w[\w-]*)/(?P<resource_name>%s)\.(?P<format>\w+)%s$" % (
self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_list'), name="api_dispatch_list"),
]
示例3: base_urls
def base_urls(self):
"""
Same as the original ``base_urls`` but supports using the custom
url_id_attribute instead of the pk of the objects.
"""
# Due to the way Django parses URLs, ``get_multiple``
# won't work without a trailing slash.
return [
url(r"^(?P<resource_name>%s)%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_list'),
name="api_dispatch_list"),
url(r"^(?P<resource_name>%s)/schema%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('get_schema'),
name="api_get_schema"),
url(r"^(?P<resource_name>%s)/set/(?P<%s_list>(%s;?)*)/$" %
(self._meta.resource_name,
self._meta.url_id_attribute,
self.get_url_id_attribute_regex()),
self.wrap_view('get_multiple'),
name="api_get_multiple"),
url(r"^(?P<resource_name>%s)/(?P<%s>%s)%s$" %
(self._meta.resource_name,
self._meta.url_id_attribute,
self.get_url_id_attribute_regex(),
trailing_slash()),
self.wrap_view('dispatch_detail'),
name="api_dispatch_detail"),
]
示例4: prepend_urls
def prepend_urls(self):
""" Add the following array of urls to the UserResource base urls """
resource_name = self._meta.resource_name
return [
# register
url(r"^(?P<resource_name>%s)/register%s$" %
(resource_name, trailing_slash()),
self.wrap_view('register'), name="api_register"),
# login
url(r"^(?P<resource_name>%s)/login%s$" %
(resource_name, trailing_slash()),
self.wrap_view('login'), name="api_login"),
# logout
url(r'^(?P<resource_name>%s)/logout%s$' %
(resource_name, trailing_slash()),
self.wrap_view('logout'), name='api_logout'),
# is_authenticated
url(r'^(?P<resource_name>%s)/is_authenticated%s$' %
(resource_name, trailing_slash()),
self.wrap_view('authenticated'), name='api_authenticated'),
# recover password
url(r'^(?P<resource_name>%s)/recover_password%s$' %
(resource_name, trailing_slash()),
self.wrap_view('recover_password'),
name='api_recover_password'),
]
示例5: prepend_urls
def prepend_urls(self):
return [
url(r"^(?P<resource_name>%s)/signin%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view('signin'), name='signin_api'),
url(r"^(?P<resource_name>%s)/signout%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view('signout'), name='signout_api'),
]
示例6: prepend_urls
def prepend_urls(self):
return [
url(r"^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/set-current%s$" % (
self._meta.resource_name, trailing_slash()), self.wrap_view('set_current'),
name="playlist_api_set_current"),
url(r"^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/reorder%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view('reorder'), name="playlist_api_reorder"),
# collecting
url(r"^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/collect%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view('collect_specific'), name="playlist_api_collect_specific"),
url(r"^(?P<resource_name>%s)/collect%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view('collect'), name="playlist_api_collect"),
# services & hooks
url(r"^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/mixdown-complete%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view('mixdown_complete'), name="alibrary-playlist_api-mixdown_complete"),
# # autocomplete
# url(r"^(?P<resource_name>%s)/autocomplete%s$" % (self._meta.resource_name, trailing_slash()),
# self.wrap_view('autocomplete'), name="alibrary-playlist_api-autocomplete"),
#
# # legacy
# url(r"^(?P<resource_name>%s)/autocomplete-name%s$" % (self._meta.resource_name, trailing_slash()),
# self.wrap_view('autocomplete'), name="alibrary-playlist_api-autocomplete"),
]
示例7: prepend_urls
def prepend_urls(self):
"""
1) + 2)
Allow login and logout via the API
cf. http://stackoverflow.com/questions/11770501/how-can-i-login-to-django-using-tastypie
3)
Allow negative primary key when requesting individual user
(Django Guardian has the convention that there exists an AnonymousUser with id=-1)
cf https://github.com/toastdriven/django-tastypie/pull/395/files
"""
return [
url(r"^(?P<resource_name>%s)/login%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('login'), name="api_login"),
url(r'^(?P<resource_name>%s)/logout%s$' %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('logout'), name='api_logout'),
url(r"^(?P<resource_name>%s)/(?P<pk>-?\w[\w/-]*)%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_detail'), name="api_dispatch_detail")
]
示例8: prepend_urls
def prepend_urls(self):
return [
url(r"^(?P<resource_name>%s)/login%s$" %(self._meta.resource_name, trailing_slash()),self.wrap_view('login'), name="api_login"),
url(r'^(?P<resource_name>%s)/logout%s$' %(self._meta.resource_name, trailing_slash()),self.wrap_view('logout'), name='api_logout'),
url(r'^(?P<resource_name>%s)/register%s$' %(self._meta.resource_name, trailing_slash()),self.wrap_view('register'), name='api_register'),
url(r'^(?P<resource_name>%s)/save_settings%s$' %(self._meta.resource_name, trailing_slash()),self.wrap_view('save_settings'), name='api_save_settings'),
]
示例9: prepend_urls
def prepend_urls(self):
return [
url(r'^(?P<resource_name>%s)/addfavr%s$' % (self._meta.resource_name, trailing_slash()), self.wrap_view('addFavR'), name = 'addFavR'),
url(r'^(?P<resource_name>%s)/addfavu%s$' % (self._meta.resource_name, trailing_slash()), self.wrap_view('addFavU'), name = 'addFavU'),
url(r'^(?P<resource_name>%s)/removefavr%s$' % (self._meta.resource_name, trailing_slash()), self.wrap_view('removeFavR'), name = 'removeFavR'),
url(r'^(?P<resource_name>%s)/removefavu%s$' % (self._meta.resource_name, trailing_slash()), self.wrap_view('removeFavU'), name = 'removeFavU'),
]
示例10: base_urls
def base_urls(self):
return [
url(r"^(?P<resource_name>%s)%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_list'), name="api_dispatch_list"),
url(r"^(?P<resource_name>%s)/schema%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('get_schema'), name="api_get_schema"),
url(r"^(?P<resource_name>%s)/set/(?P<pk_list>\w[\w;-]*)/$" % self._meta.resource_name, self.wrap_view('get_multiple'), name="api_get_multiple"),
url(r"^(?P<resource_name>%s)/(?P<pk>\w[\w-]*)%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
]
示例11: actionurls
def actionurls(self):
urls = []
for name, method in self.__class__.__dict__.iteritems():
if hasattr(method, "is_auto_action"):
actionName = name if not hasattr(method, "auto_action_name") \
else method.auto_action_name
if hasattr(method, "auto_action_url"):
urls.append(
url(method.auto_action_url,
self.wrap_view(name),
name="api_action_%s" % actionName)
)
else:
if not method.auto_action_static:
urls.append(
url(r"^(?P<resource_name>%s)/(?P<%s>[A-Za-z0-9]+)/%s%s$" % (
self._meta.resource_name,
self._meta.detail_uri_name,
actionName,
trailing_slash()),
self.wrap_view(name),
name="api_action_static_%s" % actionName)
)
else:
urls.append(
url(r"^(?P<resource_name>%s)/%s%s$" % (
self._meta.resource_name,
actionName,
trailing_slash()),
self.wrap_view(name),
name="api_action_%s" % actionName)
)
return urls
示例12: base_urls
def base_urls(self):
return [
url(r"^(?P<website_togo>\w+)%s$" % (trailing_slash()), self.wrap_view('dispatch_list'), name="api_dispatch_list"),
url(r"^(?P<website_togo>\w+)/schema%s$" % (trailing_slash()), self.wrap_view('get_schema'), name="api_get_schema"),
url(r"^(?P<website_togo>\w+)/set/(?P<pk_list>\w[\w/;-]*)/$", self.wrap_view('get_multiple'), name="api_get_multiple"),
url(r"^(?P<website_togo>\w+)/(?P<pk>\w[\w/-]*)%s$" % (trailing_slash()), self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
]
示例13: base_urls
def base_urls(self):
return [
url(
r"^(?P<resource_name>%s)%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view("dispatch_list"),
name="api_dispatch_list",
),
url(
r"^(?P<resource_name>%s)/schema%s$" % (self._meta.resource_name, trailing_slash()),
self.wrap_view("get_schema"),
name="api_get_schema",
),
url(
r"^(?P<resource_name>%s)/set/(?P<%s_list>\w[\w/;-]*)%s$"
% (self._meta.resource_name, self._meta.detail_uri_name, trailing_slash()),
self.wrap_view("get_multiple"),
name="api_get_multiple",
),
# Our lookup field.
# Slugs can't start with the _ character or contain a
# slash surrounded by the _ character. We do this so we can
# define URLs for sub-resources more easily.
url(
r"^(?P<resource_name>%s)/(?P<%s>[^_]((?!(/_)|(_/)).)*?)%s$"
% (self._meta.resource_name, self._meta.detail_uri_name, trailing_slash()),
self.wrap_view("dispatch_detail"),
name="api_dispatch_detail",
),
]
示例14: prepend_urls
def prepend_urls(self):
return [
url(r"^(?P<resource_name>%s)/(?P<pk>[0-9]+)%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
url(r"^(?P<resource_name>%s)/autocomplete%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('autocomplete'), name="api_tag_autocomplete"),
url(r"^(?P<resource_name>%s)/trending%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('get_trending'), name="api_tag_trending"),
url(r"^(?P<resource_name>%s)/nearby%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('get_nearby'), name="api_tag_nearby"),
url(r"^(?P<resource_name>%s)/by_name/(?P<tag>[\w\d]+)%s$" %
(self._meta.resource_name, trailing_slash()),
self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
]
示例15: prepend_urls
def prepend_urls(self):
return [
url(r"^(?P<resource_name>%s)/jobs%s$" % (self._meta.resource_name,
trailing_slash()), self.wrap_view('jobs'), name="jobs"),
url(r"^(?P<resource_name>%s)/crawl%s$" % (self._meta.resource_name,
trailing_slash()), self.wrap_view('crawl'), name="crawl"),
]