• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.NamespacedApi类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tastypie.api.NamespacedApi的典型用法代码示例。如果您正苦于以下问题:Python NamespacedApi类的具体用法?Python NamespacedApi怎么用?Python NamespacedApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了NamespacedApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: TastypieApiGenerator

class TastypieApiGenerator(object):
    def __init__(self, namespace):
        """
        Create api
        :param namespace: namespace should be the application name, as we'll set applications to use application name
         as the url conf namespace
        """
        super(TastypieApiGenerator, self).__init__()
        self.generator = AdvTastypieResourceGenerator()
        # The urlconf_namespace and the above NamespacedModelResource will ensure the name space is added when
        # calling reverse to get the resource uri
        self.v1_api = NamespacedApi(api_name='v1', urlconf_namespace=namespace)

    def get_model_api_url_list(self):
        url_list = [url(r'^api/',
                        include(self.v1_api.urls))]
        return url_list

    def register_all(self, models):
        for model in enum_models(models):
            if hasattr(model, "objects"):
                self.register_resource_for_model(model)

    def register_resource_for_model(self, model):
        resource = self.generator.get_resource(model)
        self.v1_api.register(resource)
开发者ID:weijia,项目名称:djangoautoconf,代码行数:26,代码来源:adv_tastypie_resource.py


示例2: register_api

def register_api():
	api = NamespacedApi(api_name='v1', urlconf_namespace='cgen')
	api.register(CharacterResource())
	api.register(ClassChassisResource())
	api.register(RaceResource())

	return api
开发者ID:Moguri,项目名称:legendgen,代码行数:7,代码来源:api.py


示例3: __init__

 def __init__(self, namespace):
     """
     Create api
     :param namespace: namespace should be the application name, as we'll set applications to use application name
      as the url conf namespace
     """
     super(TastypieApiGenerator, self).__init__()
     self.generator = AdvTastypieResourceGenerator()
     # The urlconf_namespace and the above NamespacedModelResource will ensure the name space is added when
     # calling reverse to get the resource uri
     self.v1_api = NamespacedApi(api_name='v1', urlconf_namespace=namespace)
开发者ID:weijia,项目名称:djangoautoconf,代码行数:11,代码来源:adv_tastypie_resource.py


示例4: topic_models

def topic_models(path, force=False):
    """
        Auto-discover topic-related model by looking into
        a topic package for an ontology file. This will also
        create all api resources and endpoints.

        This will create the following modules:
            {path}
            {path}.models
            {path}.resources
            {path}.summary
            {path}.urls
    """
    topic_module = import_or_create(path, force=force)
    topic_name   = path.split(".")[-1]
    # Ensure that the topic's model exist
    topic = Topic.objects.get(ontology_as_mod=topic_name)
    app_label = topic.app_label()
    # Add '.models to the path if needed
    models_path = path if path.endswith(".models") else '%s.models' % path
    urls_path   = "%s.urls" % path
    # Import or create virtually the models.py file
    models_module = import_or_create(models_path, force=force)
    try:
        # Generates all model using the ontology file.
        # Also overides the default app label to allow data persistance
        if topic.ontology_as_json is not None:
            # JSON ontology
            models = parser.json.parse(topic.ontology_as_json, path, app_label=app_label)
        elif topic.ontology_as_owl is not None:
            # OWL ontology
            models = parser.owl.parse(topic.ontology_as_owl, path, app_label=app_label)
        else:
            models = []
    # except TypeError as e:
    #    if settings.DEBUG: print 'TypeError:', e
    #    models = []
    except ValueError as e:
        if settings.DEBUG: print 'ValueError:', e
        models = []
    # Makes every model available through this module
    for m in models:
        # Record the model
        setattr(models_module, m, models[m])
    # Generates the API endpoints
    api = NamespacedApi(api_name='v1', urlconf_namespace=app_label)
    # Create resources root if needed
    resources = import_or_create("%s.resources" % path, force=force)
    # Creates a resource for each model
    for name in models:
        Resource = utils.create_model_resource(models[name])
        resource_name = "%sResource" % name
        # Register the virtual resource to by importa
        resource_path = "%s.resources.%s" % (path, resource_name)
        # This resource is now available everywhere:
        #  * as an attribute of `resources`
        #  * as a module
        setattr(resources, resource_name, Resource)
        sys.modules[resource_path] = Resource
        # And register it into the API instance
        api.register(Resource())
    # Every app have to instance a SummaryResource class
    summary_path   = "%s.summary" % path
    summary_module = import_or_create(summary_path, force=force)
    # Take the existing summary resource
    if hasattr(summary_module, 'SummaryResource'):
        SummaryResource = summary_module.SummaryResource
    # We create one if it doesn't exist
    else:
        from app.detective.topics.common.summary import SummaryResource as CommonSummaryResource
        attrs           = dict(meta=CommonSummaryResource.Meta)
        SummaryResource = type('SummaryResource', (CommonSummaryResource,), attrs)
    # Register the summary resource
    api.register(SummaryResource())
    # Create url patterns
    urlpatterns = patterns(path, url('', include(api.urls)), )
    # Import or create virtually the url path
    urls_modules = import_or_create(urls_path, force=force)
    # Merge the two url patterns if needed
    if hasattr(urls_modules, "urlpatterns"): urlpatterns += urls_modules.urlpatterns
    # Update the current url pattern
    urls_modules.urlpatterns = urlpatterns
    # API is now up and running,
    # we need to connect its url patterns to global one
    urls = importlib.import_module("app.detective.urls")
    # Add api url pattern with the highest priority
    new_patterns = patterns(app_label,
        url(r'^{0}/{1}/'.format(topic.author, topic.slug), include(urls_path, namespace=app_label) ),
    )
    if hasattr(urls, "urlpatterns"):
        # Merge with a filtered version of the urlpattern to avoid duplicates
        new_patterns += [u for u in urls.urlpatterns if getattr(u, "namespace", None) != app_label ]
    # Then update url pattern
    urls.urlpatterns = new_patterns
    # At last, force the url resolver to reload (because we update it)
    clear_url_caches()
    reload_urlconf()
    return topic_module
开发者ID:IvanJijon,项目名称:detective.io,代码行数:98,代码来源:register.py


示例5: NamespacedApi

from django.conf.urls import patterns, include, url
from .api import GameResource
from tastypie.api import NamespacedApi

v1_api = NamespacedApi(api_name='v1', urlconf_namespace='games')
v1_api.register(GameResource())

urlpatterns = patterns('',
    url(r'^api/', include(v1_api.urls)),
)
开发者ID:drahul12,项目名称:sample-project,代码行数:10,代码来源:urls.py


示例6: NamespacedApi

from django.conf.urls import patterns, url, include
from tastypie.api import NamespacedApi
from . import api
from narrative import views


narrative_api = NamespacedApi(api_name='api', urlconf_namespace='narrative')
narrative_api.register(api.DatumResource())

urlpatterns = patterns(
    '',
    url(r'^log/$', views.LogView.as_view(), name='narrative.log'),
    url(r'^', include(narrative_api.urls, namespace='narrative'))
)
开发者ID:ambitioninc,项目名称:django-narrative,代码行数:14,代码来源:urls.py


示例7: NamespacedApi

    AddAnSRedirectView, SpeechAudioCreate, SpeechCreate, SpeechUpdate,
    SpeechDelete, SpeechView, SpeakerCreate, SpeakerUpdate, SpeakerDelete, SpeakerSubscribe,
    SpeakerView, SpeakerList, SectionCreate, SectionUpdate, SectionDelete,
    SectionView, SectionViewAN, ParentlessList, RecordingList, RecordingView,
    RecordingUpdate, RecordingAPICreate, InstanceView, Select2AutoResponseView,
    PopoloImportView, AkomaNtosoImportView,
    )

from speeches.search import InstanceSearchView

try:
    from tastypie.api import NamespacedApi
    from speeches.api import SpeechResource, SpeakerResource, SectionResource
    # XXX The below assumes this app is being included with a 'speeches' namespace.
    # Unclear how to have this inherit whichever namespace is being used.
    v01_api = NamespacedApi(api_name='v0.1', urlconf_namespace='speeches')
    v01_api.register(SpeakerResource())
    v01_api.register(SpeechResource())
    v01_api.register(SectionResource())
except:
    v01_api = None

urlpatterns = [
    url(r'^$', InstanceView.as_view(), name='home'),

    # Override the usual AutoResponseView from django_select2 so as to limit
    # results by instance
    url(r"^select2/fields/auto.json$",
        Select2AutoResponseView.as_view(),
        name="django_select2_central_json"),
开发者ID:johnfelipe,项目名称:sayit,代码行数:30,代码来源:urls.py


示例8: NamespacedApi

from django.conf.urls import patterns, include, url
from django.views.generic import DetailView, ListView
from django.views.generic import TemplateView
from todo.models import TodoItem, TodoList
from todo.api import TodoListResource, UserResource
from tastypie.api import Api, NamespacedApi

v1_api = NamespacedApi(api_name='v1', urlconf_namespace='tastypie_api')
v1_api.register(UserResource())
v1_api.register(TodoListResource())

urlpatterns = patterns('',
    url(r'^$', 'todo.views.list_index', name='list_index'),
    url(r'^create/$', 'todo.views.list_create', name='list_create'),
    url(r'^delete/(?P<todolist_id>\d+)/$', 'todo.views.list_delete', name='list_delete'),
    url(r'^share/(?P<todolist_id>\d+)/$', 'todo.views.list_share', name='list_share'),
    url(r'^(?P<todolist_id>\d+)/items/$', 'todo.views.item_index', name='item_index'),
    url(r'^items/(?P<pk>\d+)/$',
        DetailView.as_view(
            model=TodoItem,
            template_name='todo/item_detail.html'),
        name='item_detail'),
    url(r'^(?P<todolist_id>\d+)/items/create/$', 'todo.views.item_create', name='item_create'),
    url(r'^items/(?P<todoitem_id>\d+)/update/$', 'todo.views.item_update', name='item_update'),
    url(r'^items/(?P<todoitem_id>\d+)/delete/$', 'todo.views.item_delete', name='item_delete'),
    url(r'^items/(?P<todoitem_id>\d+)/do/$', 'todo.views.item_do', name='item_do'),
    url(r'^denied$', TemplateView.as_view(template_name='todo/permitions_denied.html'), name='permitions_denied'),
    url(r'^api_tastypie/', include(v1_api.urls, namespace='tastypie_api')),
)
开发者ID:lyudmildrx,项目名称:exp_todo,代码行数:29,代码来源:urls.py


示例9: NamespacedApi

from django.conf.urls import patterns, include, url
from tastypie.api import NamespacedApi

from user_guide.api import GuideResource, GuideInfoResource


user_guide_api = NamespacedApi(api_name='api', urlconf_namespace='user_guide')
user_guide_api.register(GuideResource())
user_guide_api.register(GuideInfoResource())

urlpatterns = patterns(
    '',
    url(r'', include(user_guide_api.urls, namespace='user_guide'))
)
开发者ID:micahhausler,项目名称:django-user-guide,代码行数:14,代码来源:urls.py


示例10: NamespacedApi

from __future__ import absolute_import
from django.conf.urls import patterns, url, include

from . import views
from tastypie.api import NamespacedApi
from oauth2 import resource

api = NamespacedApi('v1', urlconf_namespace='oauth2')
api.register(resource.AccessTokenResource())
api.register(resource.UserResource())

urlpatterns = patterns(
    '',
    url(r'^authorize/$', views.AuthorizationView.as_view(), name="authorize"),
    url(r'^token/$', views.TokenView.as_view(), name="token"),
    url(r'^me/$', views.me_view, name='me'),
    url(r'^api/', include(api.urls)),
)

# Application management views
urlpatterns += patterns(
    '',
    url(r'^applications/$', views.ApplicationList.as_view(), name="list"),
    url(r'^applications/register/$', views.ApplicationRegistration.as_view(), name="register"),
    url(r'^applications/(?P<pk>\d+)/$', views.ApplicationDetail.as_view(), name="detail"),
    url(r'^applications/(?P<pk>\d+)/delete/$', views.ApplicationDelete.as_view(), name="delete"),
    url(r'^applications/(?P<pk>\d+)/update/$', views.ApplicationUpdate.as_view(), name="update"),
    url(r'^applications/(?P<pk>\d+)/examine/$', views.ApplicationExamine.as_view(), name='examine'),
)
开发者ID:zouyapeng,项目名称:AccountSystem,代码行数:29,代码来源:urls.py


示例11: NamespacedApi

from api.resources import TaskResource
from api.resources import BasicAuthTaskResource

from api.resources import SprintMeetingResource
from api.resources import SprintDateResource

from api.resources import TeamResource
from api.resources import TeamAttrResource

from api.resources import UserResource
from api.resources import UserPreferencesResource
from api.resources import BasicAuthUserResource


v1_api = NamespacedApi(api_name='v1', urlconf_namespace="api")
v1_api.register(CustomerResource())
v1_api.register(ProjectResource())
v1_api.register(TaskResource())
v1_api.register(BasicAuthTaskResource())
v1_api.register(SprintDateResource())
v1_api.register(SprintMeetingResource())
v1_api.register(UserResource())
v1_api.register(UserPreferencesResource())
v1_api.register(BasicAuthUserResource())
v1_api.register(TeamResource())
v1_api.register(TeamAttrResource())

urlpatterns = patterns('',
  url(r'', include(v1_api.urls, namespace='api')),
)
开发者ID:chassing,项目名称:drawupme,代码行数:30,代码来源:urls.py


示例12: NamespacedApi

"""
Djukebox URLs
"""

from django.conf.urls.defaults import patterns, url, include
from tastypie.api import NamespacedApi

from models import Mp3File, OggFile
from api import ArtistResource, AlbumResource, TrackResource, TrackAlbumResource

# There must be a better way
v1_api = NamespacedApi(api_name='v1', urlconf_namespace='djukeboxapi')
v1_api.register(ArtistResource())
v1_api.register(AlbumResource())
v1_api.register(TrackResource())
v1_api.register(TrackAlbumResource())

urlpatterns = patterns('',
                       url(r'^api/', include(v1_api.urls)),
                       url(r'^login/', 'django.contrib.auth.views.login', {'template_name': 'djukebox/login.html'}, name='djukebox-login'),
                       url(r'^logout/', 'django.contrib.auth.views.logout_then_login', name="djukebox-logout"),
                       )

urlpatterns += patterns('djukebox.views',
                       url(r'^home/', 'main', name='djukebox-home'),
                       # the following stream_list/ cannot be used directly, but can be used by {% url %} tags in
                       # templated javascript to get the base url when you don't know the track id yet
                       url(r'^stream/(?P<format>\w+)/(?P<track_id>\d+)/', 'stream_track', name='djukebox-stream'),
                       url(r'^stream/ogg/(?P<track_id>\d+)/', 'stream_track', {'format': OggFile}, name='djukebox-stream-ogg'),
                       url(r'^stream/mp3/(?P<track_id>\d+)/', 'stream_track', {'format': Mp3File}, name='djukebox-stream-mp3'),
                       url(r'^upload_track/', 'upload_track', name='djukebox-upload'),
开发者ID:jmichalicek,项目名称:djukebox,代码行数:31,代码来源:urls.py


示例13: url

  ),

  url(r'^about/$', BaseView.as_view(
      metadata='metadata/about.html'),
      name='about'
  ),

  url(r'^hut/new/$', BaseView.as_view(
      metadata='metadata/hut_new.html'),
      name='hut_new'
  ),

  url(r'^partials/(?P<template>\w+)\.html$', DynamicTemplateView.as_view(folder='partials')),
)

# api
v1_api = NamespacedApi(api_name='v1', urlconf_namespace='huts_api')
v1_api.register(RegionResource())
v1_api.register(DesignationResource())
v1_api.register(SystemResource())
v1_api.register(AccessTypeResource())
v1_api.register(HutTypeResource())
v1_api.register(ServiceResource())
v1_api.register(AgencyResource())
v1_api.register(HutResource())
v1_api.register(HutSuggestionResource())

api_patterns = patterns('',
  url(r'', include(v1_api.urls)),
)
开发者ID:dylanfprice,项目名称:hutmap,代码行数:30,代码来源:urls.py


示例14: NamespacedApi

from django.conf.urls import patterns, include

from tastypie.api import NamespacedApi

from .api import SightingResource, TreeResource, MarkerResource


v1_api = NamespacedApi(api_name='v1', urlconf_namespace='api')
v1_api.register(TreeResource())
v1_api.register(MarkerResource())
v1_api.register(SightingResource())

urlpatterns = patterns(
    '',
    (r'', include(v1_api.urls)),
)
开发者ID:sylva-foundation,项目名称:ashtag,代码行数:16,代码来源:urls.py


示例15: NamespacedApi

from django.conf import settings
from django.conf.urls import include, url
from tastypie.api import NamespacedApi
from namespaced.api.resources import NamespacedNoteResource, NamespacedUserResource


api = NamespacedApi(api_name='v1', urlconf_namespace='special')
api.register(NamespacedNoteResource(), canonical=True)
api.register(NamespacedUserResource(), canonical=True)

if settings.DJANGO_VERSION >= settings.DJANGO_19:
    included = include((api.urls, 'special'))
else:
    included = include(api.urls, namespace='special')

urlpatterns = [
    url(r'^api/', included),
]
开发者ID:7Geese,项目名称:django-tastypie,代码行数:18,代码来源:urls.py


示例16: NamespacedApi

from django.conf.urls import patterns, include, url

from tastypie.api import NamespacedApi

from .api import EmployeeResource, SettingResource

v1_api = NamespacedApi(api_name='v1', urlconf_namespace='')
v1_api.register(EmployeeResource())
v1_api.register(SettingResource())

urlpatterns = patterns('',
    url(r'^api/', include(v1_api.urls)),
)
开发者ID:anuragal,项目名称:thinrest,代码行数:13,代码来源:urls.py


示例17: NamespacedApi

from django.conf.urls import patterns, include, url
from tastypie.api import NamespacedApi

from .api import TourResource, StepResource

api = NamespacedApi(api_name='api', urlconf_namespace='tour')
api.register(TourResource())
api.register(StepResource())

urlpatterns = patterns(
    '',
    url(r'^', include(api.urls, namespace='tour')),
)
开发者ID:jmcriffey,项目名称:django-tour,代码行数:13,代码来源:urls.py


示例18: NamespacedApi

from .resources       import QuoteRequestResource, TopicNestedResource, \
                             TopicSkeletonResource, ArticleResource, \
                             SubscriptionResource, TopicDataSetResource
from .summary         import SummaryResource
from .user            import UserNestedResource, ProfileResource
from .cypher          import CypherResource
from django.conf.urls import patterns, include, url
from tastypie.api     import NamespacedApi
from .jobs            import JobResource

api = NamespacedApi(api_name='v1', urlconf_namespace='common')
api.register(QuoteRequestResource())
api.register(TopicNestedResource())
api.register(TopicSkeletonResource())
api.register(TopicDataSetResource())
api.register(SummaryResource())
api.register(CypherResource())
api.register(ProfileResource())
api.register(UserNestedResource())
api.register(ArticleResource())
api.register(JobResource())
api.register(SubscriptionResource())

urlpatterns = patterns('common',
    url(r'', include(api.urls)),
)

开发者ID:IvanJijon,项目名称:detective.io,代码行数:26,代码来源:urls.py


示例19: NamespacedApi

from tastypie.api import NamespacedApi

from resources import DocumentationResource
from resources import CategoryResource


v1_api = NamespacedApi(api_name='v1')

v1_api.register(DocumentationResource())
v1_api.register(CategoryResource())
开发者ID:chassing,项目名称:instadoc,代码行数:10,代码来源:__init__.py


示例20: NamespacedApi

from django.conf.urls import patterns, url, include

from tastypie.api import NamespacedApi

from apps.graph.api import ConceptResource, GraphResource, ConceptResourceResource, DependencyResource, GoalResource,\
    TargetGraphResource, FullTargetGraphResource, GlobalResourceResource, ResourceLocationResource
from views import *

# api v1
v1_api = NamespacedApi(api_name='v1', urlconf_namespace='graphs')
v1_api.register(ConceptResource())
v1_api.register(ConceptResourceResource())
v1_api.register(GlobalResourceResource())
v1_api.register(ResourceLocationResource())
v1_api.register(GraphResource())
v1_api.register(TargetGraphResource())
v1_api.register(FullTargetGraphResource())
v1_api.register(DependencyResource())
v1_api.register(GoalResource())

#import pdb; pdb.set_trace()

# TODO refactor concepts
urlpatterns = patterns('',
                       url(r'^$', "django.views.defaults.page_not_found"),
                       url(r'^concept-triplet/?$', get_concept_triplet, name='concept_triplet'),
                       url(r'^autocomplete/?$', get_autocomplete, name='autocomplete'),
                       url(r'^(?i)concepts/([^/]+)/history/?$', get_concept_history, name="concept-history"),
                       url(r'^(?i)concepts/([^/]+)/?$', get_concept_dep_graph, name="concepts"),
                       url(r'^(?i)concepts/$', "django.views.defaults.page_not_found", name="concepts-base"),
                       #                  url(r'^(?i)concepts/([^/]+)?/version/(\d+)/?$', get_concept_version, name="concept-version"),
开发者ID:NoriVicJr,项目名称:metacademy-application,代码行数:31,代码来源:urls.py



注:本文中的tastypie.api.NamespacedApi类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python authentication.ApiKeyAuthentication类代码示例发布时间:2022-05-27
下一篇:
Python api.Api类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap