当前位置: 首页>>代码示例>>Python>>正文


Python api.namespace函数代码示例

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


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

示例1: import

from flask_security import current_user
from flask_restplus.inputs import boolean

from udata.auth import admin_permission
from udata.api import api, API, fields
from udata.core.user.api_fields import user_ref_fields

from .forms import DiscussionCreateForm, DiscussionCommentForm
from .models import Message, Discussion
from .permissions import CloseDiscussionPermission
from .signals import (
    on_new_discussion, on_new_discussion_comment, on_discussion_closed,
    on_discussion_deleted
)

ns = api.namespace('discussions', 'Discussion related operations')

message_fields = api.model('DiscussionMessage', {
    'content': fields.String(description='The message body'),
    'posted_by': fields.Nested(user_ref_fields,
                               description='The message author'),
    'posted_on': fields.ISODateTime(description='The message posting date'),
})

discussion_fields = api.model('Discussion', {
    'id': fields.String(description='The discussion identifier'),
    'subject': fields.Nested(api.model_reference,
                             description='The discussion target object'),
    'class': fields.ClassName(description='The object class',
                              discriminator=True),
    'title': fields.String(description='The discussion title'),
开发者ID:opendatateam,项目名称:udata,代码行数:31,代码来源:api.py

示例2: line

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, API
from udata.auth import admin_permission


from udata.core.dataset.api_fields import dataset_ref_fields
from udata.core.reuse.api_fields import reuse_ref_fields
from udata.core.user.api_fields import user_ref_fields

from .models import Post
from .forms import PostForm

ns = api.namespace('posts', 'Posts related operations')

post_fields = api.model('Post', {
    'id': fields.String(description='The post identifier'),
    'name': fields.String(description='The post name', required=True),
    'slug': fields.String(description='The post permalink string', readonly=True),
    'headline': fields.String(description='The post headline', required=True),
    'content': fields.Markdown(description='The post content in Markdown', required=True),

    'image': fields.ImageField(description='The post image'),
    'credit_to': fields.String(description='An optionnal credit line (associated to the image)'),
    'credit_url': fields.String(description='An optionnal link associated to the credits'),

    'tags': fields.List(fields.String, description='Some keywords to help in search'),
    'datasets': fields.List(fields.Nested(dataset_ref_fields), description='The post datasets'),
    'reuses': fields.List(fields.Nested(reuse_ref_fields), description='The post reuses'),
开发者ID:guillo-w,项目名称:udata,代码行数:30,代码来源:api.py

示例3: ReuseListAPI

# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from udata.api import api, API, ModelAPI, ModelListAPI, SingleObjectAPI
from udata.forms import ReuseForm
from udata.models import Reuse

from udata.core.issues.api import IssuesAPI
from udata.core.followers.api import FollowAPI

from .api_fields import reuse_fields, reuse_page_fields
from .models import ReuseIssue, FollowReuse
from .search import ReuseSearch

ns = api.namespace('reuses', 'Reuse related operations')

common_doc = {
    'params': {'reuse': 'The reuse ID or slug'}
}


@ns.route('/', endpoint='reuses')
@api.doc(get={'model': reuse_page_fields}, post={'model': reuse_fields})
class ReuseListAPI(ModelListAPI):
    model = Reuse
    form = ReuseForm
    fields = reuse_fields
    search_adapter = ReuseSearch

开发者ID:pombredanne,项目名称:udata,代码行数:29,代码来源:api.py

示例4: Blueprint

from udata.api import api
from udata.models import db

from udata.core.metrics.models import WithMetrics
from udata.core.user.views import blueprint as user_bp

from udata.core.issues.models import Issue, Message, ISSUE_TYPES
from udata.core.issues.metrics import IssuesMetric
from udata.core.issues.api import IssuesAPI

from .api import APITestCase
from .factories import faker, UserFactory


bp = Blueprint('test_issues', __name__)
ns = api.namespace('test', 'A test namespace')


class Fake(WithMetrics, db.Document):
    name = db.StringField()


class FakeIssue(Issue):
    subject = db.ReferenceField(Fake)


class FakeIssuesMetric(IssuesMetric):
    model = Fake


@ns.route('/<id>/issues/', endpoint='fake_issues')
开发者ID:pombredanne,项目名称:udata,代码行数:31,代码来源:test_issues.py

示例5:

from datetime import datetime

from flask.ext.security import current_user
from flask_restful.inputs import boolean

from udata.api import api, API, fields
from udata.models import Dataset, DatasetIssue, Reuse, ReuseIssue
from udata.core.user.api_fields import user_ref_fields

from .forms import IssueCommentForm, IssueCreateForm
from .models import Message, Issue
from .permissions import CloseIssuePermission
from .signals import on_new_issue, on_new_issue_comment, on_issue_closed

ns = api.namespace('issues', 'Issue related operations')

message_fields = api.model('IssueMessage', {
    'content': fields.String(description='The message body', required=True),
    'posted_by': fields.Nested(
        user_ref_fields, description='The message author', required=True),
    'posted_on': fields.ISODateTime(
        description='The message posting date', required=True),
})

issue_fields = api.model('Issue', {
    'id': fields.String(description='The issue identifier', readonly=True),
    'subject': fields.String(
        attribute='subject.id',
        description='The issue target object identifier', required=True),
    'class': fields.ClassName(description='The object class',
开发者ID:anukat2015,项目名称:udata,代码行数:30,代码来源:api.py

示例6: TransferRequestAPI

            description=("The user or organization currently owning " "the transfered object"),
        ),
        "recipient": fields.Polymorph(
            person_mapping, readonly=True, description=("The user or organization receiving " "the transfered object")
        ),
        "subject": fields.Polymorph(subject_mapping, readonly=True, description="The transfered object"),
        "comment": fields.String(readonly=True, description="A comment about the transfer request"),
        "created": fields.ISODateTime(description="The transfer request date", readonly=True),
        "status": fields.String(enum=TRANSFER_STATUS.keys(), description="The current transfer request status"),
        "responded": fields.ISODateTime(description="The transfer response date", readonly=True),
        "reponse_comment": fields.String(readonly=True, description="A comment about the transfer response"),
    },
)


ns = api.namespace("transfer")


@ns.route("/", endpoint="transfers")
class TransferRequestAPI(API):
    @api.doc("list_transfers")
    @api.marshal_list_with(transfer_fields)
    def get(self):
        """List all transfer requests"""
        pass

    @api.doc("request_transfer")
    @api.expect(transfer_request_fields)
    @api.marshal_with(transfer_fields)
    def post(self):
        """Initiate transfer request"""
开发者ID:ldolberg,项目名称:udata,代码行数:31,代码来源:api.py

示例7: MeAPI

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from flask.ext.security import current_user

from udata.api import api, ModelAPI, API
from udata.models import User, FollowUser, Reuse
from udata.forms import UserProfileForm

from udata.core.followers.api import FollowAPI
from udata.core.reuse.api_fields import reuse_fields

from .api_fields import user_fields

ns = api.namespace('users', 'User related operations')


@api.route('/me/', endpoint='me')
class MeAPI(ModelAPI):
    model = User
    form = UserProfileForm
    fields = user_fields
    decorators = [api.secure]

    def get_or_404(self, **kwargs):
        if not current_user.is_authenticated():
            api.abort(404)
        return current_user._get_current_object()


@api.route('/me/reuses/', endpoint='my_reuses')
开发者ID:pombredanne,项目名称:udata,代码行数:31,代码来源:api.py

示例8: import

from udata.api import api, API, fields
from udata.auth import admin_permission

from udata.core.dataset.api_fields import dataset_ref_fields, dataset_fields
from udata.core.organization.api_fields import org_ref_fields
from udata.core.organization.permissions import EditOrganizationPermission
from udata.core.user.api_fields import user_ref_fields

from . import actions
from .forms import HarvestSourceForm, HarvestSourceValidationForm
from .models import (
    HARVEST_JOB_STATUS, HARVEST_ITEM_STATUS, HarvestJob,
    VALIDATION_STATES, VALIDATION_ACCEPTED
)

ns = api.namespace('harvest', 'Harvest related operations')

backends_ids = [b.name for b in actions.list_backends()]

error_fields = api.model('HarvestError', {
    'created_at': fields.ISODateTime(description='The error creation date',
                                     required=True),
    'message': fields.String(description='The error short message',
                             required=True),
    'details': fields.String(description='Optionnal details (ie. stacktrace)'),
})

item_fields = api.model('HarvestItem', {
    'remote_id': fields.String(description='The item remote ID to process',
                               required=True),
    'dataset': fields.Nested(dataset_ref_fields,
开发者ID:anukat2015,项目名称:udata,代码行数:31,代码来源:api.py

示例9: SuggestTagsAPI

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata import search
from udata.api import api, API

from udata.tags import normalize  # TODO: merge this into this package

DEFAULT_SIZE = 8

ns = api.namespace('tags', 'Tags related operations')

parser = api.parser()
parser.add_argument(
    'q', type=unicode, help='The string to autocomplete/suggest',
    location='args', required=True)
parser.add_argument(
    'size', type=int, help='The amount of suggestion to fetch',
    location='args', default=DEFAULT_SIZE)


@ns.route('/suggest/', endpoint='suggest_tags')
class SuggestTagsAPI(API):
    @api.doc('suggest_tags')
    @api.expect(parser)
    def get(self):
        '''Suggest tags'''
        args = parser.parse_args()
        q = normalize(args['q'])
        result = search.suggest(q, 'tag_suggest', args['size'])
        return sorted(result, key=lambda o: len(o['text']))
开发者ID:opendatateam,项目名称:udata,代码行数:31,代码来源:api.py

示例10:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, API
from udata.auth import admin_permission


from udata.core.dataset.api_fields import dataset_fields
from udata.core.reuse.api_fields import reuse_fields
from udata.core.user.api_fields import user_ref_fields

from .models import Topic
from .forms import TopicForm

ns = api.namespace('topics', 'Topics related operations')

topic_fields = api.model('Topic', {
    'id': fields.String(description='The topic identifier'),
    'name': fields.String(description='The topic name', required=True),
    'slug': fields.String(
        description='The topic permalink string', readonly=True),
    'description': fields.Markdown(
        description='The topic description in Markdown', required=True),
    'tags': fields.List(
        fields.String, description='Some keywords to help in search', required=True),
    'datasets': fields.List(
        fields.Nested(dataset_fields), description='The topic datasets'),
    'reuses': fields.List(
        fields.Nested(reuse_fields), description='The topic reuses'),
    'featured': fields.Boolean(description='Is the topic featured'),
    'private': fields.Boolean(description='Is the topic private'),
开发者ID:odtvince,项目名称:udata,代码行数:31,代码来源:api.py

示例11: import

from .api_fields import (
    level_fields,
    granularity_fields,
    zone_suggestion_fields,
    feature_collection_fields,
)
from .models import GeoZone, GeoLevel, spatial_granularities


GEOM_TYPES = (
    'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString',
    'MultiPolygon'
)


ns = api.namespace('spatial', 'Spatial references')

suggest_parser = api.parser()
suggest_parser.add_argument(
    'q', type=unicode, help='The string to autocomplete/suggest',
    location='args', required=True)
suggest_parser.add_argument(
    'size', type=int, help='The amount of suggestion to fetch',
    location='args', default=10)

dataset_parser = api.parser()
dataset_parser.add_argument(
    'dynamic', type=inputs.boolean, help='Append dynamic datasets',
    location='args', required=False)
dataset_parser.add_argument(
    'size', type=int, help='The amount of datasets to fetch',
开发者ID:odtvince,项目名称:udata,代码行数:31,代码来源:api.py

示例12: SuggestTagsAPI

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, API, fields
from udata.search import es

DEFAULT_SIZE = 8

ns = api.namespace('suggest', 'Completion suggester APIs')

parser = api.parser()
parser.add_argument('q', type=str, help='The string to autocomplete/suggest', location='args', required=True)
parser.add_argument('size', type=int, help='The amount of suggestion to fetch', location='args', default=DEFAULT_SIZE)


@ns.route('/tags', endpoint='suggest_tags', doc={'parser': parser})
class SuggestTagsAPI(API):
    def get(self):
        '''Suggest tags'''
        args = parser.parse_args()
        result = es.suggest(index=es.index_name, body={
            'tags': {
                'text': args['q'],
                'completion': {
                    'field': 'tag_suggest',
                    'size': args['size'],
                }
            }
        })
        if 'tags' not in result:
            return []
开发者ID:pombredanne,项目名称:udata,代码行数:31,代码来源:api.py

示例13: NotificationsAPI

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from udata.api import api, fields, API
from udata.auth import current_user

from .actions import get_notifications

notifs = api.namespace('notifications', 'Notifications API')

notifications_fields = api.model('Notification', {
    'type': fields.String(description='The notification type', readonly=True),
    'created_on': fields.ISODateTime(
        description='The notification creation datetime', readonly=True),
    'details': fields.Raw(
        description='Key-Value details depending on notification type',
        readonly=True)
})


@notifs.route('/', endpoint='notifications')
class NotificationsAPI(API):
    @api.secure
    @api.doc('get_notifications')
    @api.marshal_list_with(notifications_fields)
    def get(self):
        '''List all current user pending notifications'''
        user = current_user._get_current_object()
        return get_notifications(user)
开发者ID:anukat2015,项目名称:udata,代码行数:29,代码来源:api.py

示例14: OrganizationListAPI

    request_fields,
    member_fields,
    refuse_membership_fields,
)

from udata.core.dataset.api_fields import dataset_full_fields
from udata.core.dataset.models import Dataset
from udata.core.discussions.api import discussion_fields
from udata.core.discussions.models import Discussion
from udata.core.issues.api import issue_fields
from udata.core.issues.models import Issue
from udata.core.reuse.api_fields import reuse_fields
from udata.core.reuse.models import Reuse
from udata.core.storages.api import uploaded_image_fields, image_parser, parse_uploaded_image

ns = api.namespace("organizations", "Organization related operations")
search_parser = api.search_parser(OrganizationSearch)

common_doc = {"params": {"org": "The organization ID or slug"}}


@ns.route("/", endpoint="organizations")
class OrganizationListAPI(API):
    """Organizations collection endpoint"""

    @api.doc("list_organizations", parser=search_parser)
    @api.marshal_with(org_page_fields)
    def get(self):
        """List or search all organizations"""
        return search.query(OrganizationSearch, **multi_to_dict(request.args))
开发者ID:javanna2000,项目名称:udata,代码行数:30,代码来源:api.py

示例15:

from __future__ import unicode_literals

from celery import states
from celery.result import AsyncResult
from celery.utils import get_full_cls_name
from celery.utils.encoding import safe_repr
from flask import request

from udata.api import api, API, fields
from udata.auth import admin_permission
from udata.tasks import schedulables, celery

from .forms import CrontabTaskForm, IntervalTaskForm
from .models import PeriodicTask, PERIODS

ns = api.namespace('workers', 'Asynchronous workers related operations', path='')

crontab_fields = api.model('Crontab', {
    'minute': fields.String(description='Cron expression for minute', required=True, default='*'),
    'hour': fields.String(description='Cron expression for hour', required=True, default='*'),
    'day_of_week': fields.String(description='Cron expression for day of week', required=True, default='*'),
    'day_of_month': fields.String(description='Cron expression for day of month', required=True, default='*'),
    'month_of_year': fields.String(description='Cron expression for month of year', required=True, default='*'),
})

interval_fields = api.model('Interval', {
    'every': fields.Integer(description='The interval without unit', required=True),
    'period': fields.String(description='The period/interval type', required=True, enum=PERIODS),
})

job_fields = api.model('Job', {
开发者ID:guillo-w,项目名称:udata,代码行数:31,代码来源:api.py


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