本文整理汇总了Python中piston.emitters.Emitter.unregister方法的典型用法代码示例。如果您正苦于以下问题:Python Emitter.unregister方法的具体用法?Python Emitter.unregister怎么用?Python Emitter.unregister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类piston.emitters.Emitter
的用法示例。
在下文中一共展示了Emitter.unregister方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Resource
# 需要导入模块: from piston.emitters import Emitter [as 别名]
# 或者: from piston.emitters.Emitter import unregister [as 别名]
'method': self.handler.__class__.__name__,
'query_string': request.META['QUERY_STRING'],
'timestamp': datetime.datetime.utcnow()})
except AttributeError:
pass
return resp
else:
authorizer = None
Resource = piston.resource.Resource
Emitter.register('json', BillyJSONEmitter, 'application/json; charset=utf-8')
Emitter.register('ics', ICalendarEmitter, 'text/calendar')
Emitter.unregister('yaml')
Emitter.unregister('xml')
Emitter.unregister('django')
Emitter.unregister('pickle')
all_metadata_handler = Resource(handlers.AllMetadataHandler,
authentication=authorizer)
metadata_handler = Resource(handlers.MetadataHandler,
authentication=authorizer)
bill_handler = Resource(handlers.BillHandler,
authentication=authorizer)
bill_search_handler = Resource(handlers.BillSearchHandler,
authentication=authorizer)
legislator_handler = Resource(handlers.LegislatorHandler,
authentication=authorizer)
legsearch_handler = Resource(handlers.LegislatorSearchHandler,
示例2: getattr
# 需要导入模块: from piston.emitters import Emitter [as 别名]
# 或者: from piston.emitters.Emitter import unregister [as 别名]
from django.conf.urls.defaults import *
from piston.resource import Resource
from piston.emitters import Emitter
from fiftystates.site.api.handlers import *
from fiftystates.site.api.emitters import LoggingJSONEmitter, LoggingXMLEmitter
from fiftystates.site.api.views import document
if getattr(settings, 'USE_LOCKSMITH', False):
from locksmith.auth.authentication import PistonKeyAuthentication
authorizer = PistonKeyAuthentication()
Emitter.register('json', LoggingJSONEmitter,
'application/json; charset=utf-8')
# disable XML output
Emitter.unregister('xml')
else:
authorizer = None
metadata_handler = Resource(MetadataHandler, authentication=authorizer)
bill_handler = Resource(BillHandler, authentication=authorizer)
bill_search_handler = Resource(BillSearchHandler, authentication=authorizer)
legislator_handler = Resource(LegislatorHandler, authentication=authorizer)
legsearch_handler = Resource(LegislatorSearchHandler,
authentication=authorizer)
legislator_geo_handler = Resource(LegislatorGeoHandler,
authentication=authorizer)
committee_handler = Resource(CommitteeHandler, authentication=authorizer)
committee_search_handler = Resource(CommitteeSearchHandler,
authentication=authorizer)
stats_handler = Resource(StatsHandler, authentication=authorizer)
示例3: patterns
# 需要导入模块: from piston.emitters import Emitter [as 别名]
# 或者: from piston.emitters.Emitter import unregister [as 别名]
from django.conf.urls.defaults import url, patterns, include
from dcapi.common.emitters import StreamingCSVEmitter, StreamingJSONEmitter, ExcelEmitter
from piston.emitters import Emitter
Emitter.register("json", StreamingJSONEmitter, "application/json; charset=utf-8")
Emitter.register("csv", StreamingCSVEmitter, "text/csv; charset=utf-8")
Emitter.register("xls", ExcelEmitter, "application/vnd.ms-excel; charset=utf-8")
Emitter.unregister("django")
Emitter.unregister("pickle")
Emitter.unregister("xml")
Emitter.unregister("yaml")
urlpatterns = patterns(
"",
# each data set has its own area of the API and has its own
# namespace. 'entities' is a core/common element to all APIs, and
# aggregates has also been de-coupled from the contributions API.
url(r"^entities", include("dcapi.aggregates.entities.urls")),
url(r"^contracts", include("dcapi.contracts.urls")),
# url(r'^contributions/bundled/', include('dcapi.contributions.bundling.urls')),
url(r"^contributions", include("dcapi.contributions.urls")),
url(r"^grants", include("dcapi.grants.urls")),
url(r"^lobbying", include("dcapi.lobbying.urls")),
url(r"^earmarks", include("dcapi.earmarks.urls")),
url(r"^misconduct", include("dcapi.contractor_misconduct.urls")),
url(r"^epa", include("dcapi.epa.urls")),
url(r"^faca", include("dcapi.faca.urls")),
url(r"^fara", include("dcapi.fara.urls")),
url(r"^aggregates/", include("dcapi.aggregates.urls")),
url(r"^refine/", include("dcapi.reconcile.urls")),
url(r"^", include("dcapi.rapportive.urls")),
示例4: CSVEmitter
# 需要导入模块: from piston.emitters import Emitter [as 别名]
# 或者: from piston.emitters.Emitter import unregister [as 别名]
seria = json.json.dumps(self.construct(), cls=DateTimeAwareJSONEncoder,
sort_keys=True, ensure_ascii=False)
else:
seria = simplejson.dumps(self.construct(), cls=DateTimeAwareJSONEncoder,
sort_keys=True, ensure_ascii=False)
if sig:
if should_cache:
cache.set(sig, seria, cache_timeout)
# Callback
if cb:
return '%s(%s)' % (cb, seria)
return seria
Emitter.unregister('json')
Emitter.register('json', CachedJSONEmitter, 'application/json; charset=utf-8')
Mimer.register(simplejson.loads, ('application/json',))
class CSVEmitter(Emitter):
"""
Emitter for Comma Separated Values.
"""
def render(self, request, *args, **kwargs):
f = StringIO.StringIO()
out = csv.writer(f,dialect='excel')
c = self.construct()
if not bool(request.REQUEST.get('headerless', False)):
out.writerow(self.fields)
示例5: DOC4XMLEmitter
# 需要导入模块: from piston.emitters import Emitter [as 别名]
# 或者: from piston.emitters.Emitter import unregister [as 别名]
#-*- coding:utf-8 -*-
from piston.emitters import Emitter, XMLEmitter, YAMLEmitter, JSONEmitter, PickleEmitter
from django.utils.encoding import smart_unicode
from doc4.models import Package, Repository
#Creat custom emitter if required, and register it like this:
#Emitter.register('xml', XMLEmitter, 'text/xml; charset=utf-8')
Emitter.unregister('django')
Emitter.unregister('xml')
class DOC4XMLEmitter(XMLEmitter):
def _to_xml(self, xml, data, startelement='resource'):
startelements = {
'packages' : 'package',
'repositories' : 'repository',
'files' : 'file',
'changelogs' : 'changelog',
'obsoletes' : 'obsolete',
'conflicts' : 'conflict',
'suggests' : 'suggestion',
'scripts' : 'script',
'requires' : 'required',
'provides' : 'provided',
'sub_categories' : 'sub_category',
'categories' : 'category',
}
startelement = startelements.get(startelement, startelement)
if isinstance(data, (list, tuple)):
for item in data:
示例6: queryset
# 需要导入模块: from piston.emitters import Emitter [as 别名]
# 或者: from piston.emitters.Emitter import unregister [as 别名]
allowed_methods = ('GET',)
fields = ['id',
'first_name',
'last_name',
'tags',
'photo',
('affiliations',
('id',
('role',
('title',
('content_type',
('model',)))),
('content_object',
('id',
('authorities',('id',('content_object',('abbreviation','id',)))),
'title',
'first_name',
'last_name')),
('content_type',
('model',))),
)
]
model = Staff
def queryset(self,request):
return self.model.objects.all().order_by('last_name','first_name')
Emitter.unregister('django')
Emitter.unregister('pickle')