本文整理汇总了Python中indico.web.http_api.metadata.serializer.Serializer.create方法的典型用法代码示例。如果您正苦于以下问题:Python Serializer.create方法的具体用法?Python Serializer.create怎么用?Python Serializer.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.web.http_api.metadata.serializer.Serializer
的用法示例。
在下文中一共展示了Serializer.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process(self):
filename = "%s-Categ.atom" % self._target.getName().replace("/", "")
hook = CategoryEventHook({'from': 'today'}, 'categ', {'idlist': self._target.getId(), 'dformat': 'atom'})
res = hook(self.getAW())
resultFossil = {'results': res[0], 'url': str(self._uh.getURL(self._target))}
serializer = Serializer.create('atom')
return send_file(filename, StringIO(serializer(resultFossil)), 'ATOM')
示例2: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process( self ):
filename = "%s-Session.ics"%self._session.getTitle()
hook = SessionHook({}, 'session', {'event': self._conf.getId(), 'idlist':self._session.getId(), 'dformat': 'ics'})
res = hook(self.getAW())
resultFossil = {'results': res[0]}
serializer = Serializer.create('ics')
return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
示例3: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process(self):
filename = "%s-Event.ics" % self._target.getTitle()
hook = CategoryEventHook({'detail': self._detailLevel}, 'event',
{'idlist': self._conf.getId(), 'dformat': 'ics'})
res = hook(self.getAW())
resultFossil = {'results': res[0]}
serializer = Serializer.create('ics')
return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
示例4: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process( self ):
if not self._target.isScheduled():
raise NoReportError(_("You cannot export the contribution with id %s because it is not scheduled")%self._target.getId())
filename = "%s-Contribution.ics"%self._target.getTitle()
hook = ContributionHook({}, 'contribution', {'event': self._conf.getId(), 'idlist':self._contrib.getId(), 'dformat': 'ics'})
res = hook(self.getAW())
resultFossil = {'results': res[0]}
serializer = Serializer.create('ics')
return send_file(filename, StringIO(serializer(resultFossil)), 'ICAL')
示例5: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process( self ):
hook = CategoryEventHook({'from': ['today']}, 'categ', {'idlist':self._target.getId(), 'dformat': 'atom'})
res = hook(self.getAW(), self._req)
resultFossil = {'results': res[0], 'url': str(self._uh.getURL(self._target))}
serializer = Serializer.create('atom')
data = serializer(resultFossil)
cfg = Config.getInstance()
mimetype = cfg.getFileTypeMimeType( "ATOM" )
self._req.content_type = """%s"""%(mimetype)
return data
示例6: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process(self):
hook = CategoryEventHook({"from": ["today"]}, "categ", {"idlist": self._target.getId(), "dformat": "atom"})
res = hook(self.getAW(), self._req)
resultFossil = {"results": res[0], "url": str(self._uh.getURL(self._target))}
serializer = Serializer.create("atom")
data = serializer(resultFossil)
cfg = Config.getInstance()
mimetype = cfg.getFileTypeMimeType("ATOM")
self._req.content_type = """%s""" % (mimetype)
return data
示例7: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process( self ):
filename = "%s-Session.ics"%self._session.getTitle()
hook = SessionHook({}, 'session', {'event': self._conf.getId(), 'idlist':self._session.getId(), 'dformat': 'ics'})
res = hook(self.getAW(), self._req)
resultFossil = {'results': res[0]}
serializer = Serializer.create('ics')
data = serializer(resultFossil)
self._req.headers_out["Content-Length"] = "%s"%len(data)
cfg = Config.getInstance()
mimetype = cfg.getFileTypeMimeType( "ICAL" )
self._req.content_type = """%s"""%(mimetype)
self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%cleanHTMLHeaderFilename(filename)
return data
示例8: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process(self):
if not self._target.isScheduled():
raise NoReportError(
_("You cannot export the contribution with id {0} because it is not scheduled").format(
self._target.getId()
)
)
filename = "{0}-Contribution.ics".format(self._target.getTitle())
hook = ContributionHook(
{}, "contribution", {"event": self._conf.getId(), "idlist": self._contrib.getId(), "dformat": "ics"}
)
res = hook(self.getAW())
resultFossil = {"results": res[0]}
serializer = Serializer.create("ics")
return send_file(filename, StringIO(serializer(resultFossil)), "ICAL")
示例9: _process
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def _process( self ):
if not self._target.isScheduled():
raise NoReportError(_("You cannot export the contribution with id %s because it is not scheduled")%self._target.getId())
filename = "%s-Contribution.ics"%self._target.getTitle()
hook = ContributionHook({}, 'contribution', {'event': self._conf.getId(), 'idlist':self._contrib.getId(), 'dformat': 'ics'})
res = hook(self.getAW(), self._req)
resultFossil = {'results': res[0]}
serializer = Serializer.create('ics')
data = serializer(resultFossil)
self._req.headers_out["Content-Length"] = "%s"%len(data)
cfg = Config.getInstance()
mimetype = cfg.getFileTypeMimeType( "ICAL" )
self._req.content_type = """%s"""%(mimetype)
self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%cleanHTMLHeaderFilename(filename)
return data
示例10: schema
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
pass # retry
else:
break
else:
# No need to commit stuff if we didn't use an API key
# (nothing was written)
if minfo.getRoomBookingModuleActive():
Factory.getDALManager().rollback()
Factory.getDALManager().disconnect()
dbi.endRequest(False)
# Log successful POST api requests
if error is None and req.method == 'POST':
logger.info('API request: %s?%s' % (path, query))
serializer = Serializer.create(dformat, pretty=pretty, typeMap=typeMap,
**remove_lists(queryParams))
if error:
if not serializer.schemaless:
# if our serializer has a specific schema (HTML, ICAL, etc...)
# use JSON, since it is universal
serializer = Serializer.create('json')
result = fossilize(error)
else:
if serializer.encapsulate:
result = fossilize(HTTPAPIResult(result, path, query, ts, complete, extra), IHTTPAPIExportResultFossil)
del result['_fossil']
try:
data = serializer(result)
serializer.set_headers(req)
示例11: schema
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
pass # retry
else:
break
else:
# No need to commit stuff if we didn't use an API key
# (nothing was written)
if minfo.getRoomBookingModuleActive():
Factory.getDALManager().rollback()
Factory.getDALManager().disconnect()
dbi.endRequest(False)
# Log successful POST api requests
if error is None and request.method == 'POST':
logger.info('API request: %s?%s' % (path, query))
serializer = Serializer.create(dformat, pretty=pretty, typeMap=typeMap,
**queryParams)
if error:
if not serializer.schemaless:
# if our serializer has a specific schema (HTML, ICAL, etc...)
# use JSON, since it is universal
serializer = Serializer.create('json')
result = fossilize(error)
else:
if serializer.encapsulate:
result = fossilize(HTTPAPIResult(result, path, query, ts, complete, extra), IHTTPAPIExportResultFossil)
del result['_fossil']
try:
data = serializer(result)
serializer.set_headers(responseUtil)
示例12: normalizeQuery
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
if ak and error is None:
# Commit only if there was an API key and no error
norm_path, norm_query = normalizeQuery(path, query, remove=('signature', 'timestamp'), separate=True)
uri = to_unicode('?'.join(filter(None, (norm_path, norm_query))))
ak.register_used(request.remote_addr, uri, not onlyPublic)
transaction.commit()
else:
# No need to commit stuff if we didn't use an API key (nothing was written)
# XXX do we even need this?
transaction.abort()
# Log successful POST api requests
if error is None and request.method == 'POST':
logger.info('API request: %s?%s' % (path, query))
serializer = Serializer.create(dformat, query_params=queryParams, pretty=pretty, typeMap=typeMap,
**hook.serializer_args)
if error:
if not serializer.schemaless:
# if our serializer has a specific schema (HTML, ICAL, etc...)
# use JSON, since it is universal
serializer = Serializer.create('json')
result = fossilize(error)
else:
if serializer.encapsulate:
result = fossilize(HTTPAPIResult(result, path, query, ts, complete, extra), IHTTPAPIExportResultFossil)
del result['_fossil']
try:
data = serializer(result)
serializer.set_headers(responseUtil)
示例13: get_session_ical_file
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def get_session_ical_file(sess):
from indico.web.http_api.metadata.serializer import Serializer
data = {'results': serialize_session_for_ical(sess) if sess.start_dt and sess.end_dt else []}
serializer = Serializer.create('ics')
return BytesIO(serializer(data))
示例14: get_contribution_ical_file
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
def get_contribution_ical_file(contrib):
data = {'results': serialize_contribution_for_ical(contrib)}
serializer = Serializer.create('ics')
return BytesIO(serializer(data))
示例15: schema
# 需要导入模块: from indico.web.http_api.metadata.serializer import Serializer [as 别名]
# 或者: from indico.web.http_api.metadata.serializer.Serializer import create [as 别名]
except ConflictError:
pass # retry
else:
break
else:
# No need to commit stuff if we didn't use an API key
# (nothing was written)
dbi.endRequest(False)
LDAPConnector.destroy()
# Log successful POST api requests
if error is None and request.method == 'POST':
logger.info('API request: %s?%s' % (path, query))
serializer = Serializer.create(dformat, pretty=pretty, typeMap=typeMap,
**hook.serializer_args)
if error:
if not serializer.schemaless:
# if our serializer has a specific schema (HTML, ICAL, etc...)
# use JSON, since it is universal
serializer = Serializer.create('json')
result = fossilize(error)
else:
if serializer.encapsulate:
result = fossilize(HTTPAPIResult(result, path, query, ts, complete, extra), IHTTPAPIExportResultFossil)
del result['_fossil']
try:
data = serializer(result)
serializer.set_headers(responseUtil)