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


Python serializer.Serializer类代码示例

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


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

示例1: _process

 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')
开发者ID:Json-Andriopoulos,项目名称:indico,代码行数:7,代码来源:categoryDisplay.py

示例2: _process

    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')
开发者ID:jacquesd,项目名称:indico,代码行数:9,代码来源:sessionDisplay.py

示例3: _process

    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')
开发者ID:MichelCordeiro,项目名称:indico,代码行数:10,代码来源:conferenceDisplay.py

示例4: _process

    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')
开发者ID:ferhatelmas,项目名称:indico,代码行数:13,代码来源:contribDisplay.py

示例5: _process

    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
开发者ID:jt1,项目名称:indico,代码行数:14,代码来源:categoryDisplay.py

示例6: _process

    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
开发者ID:vstitches,项目名称:indico,代码行数:14,代码来源:categoryDisplay.py

示例7: _process

    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
开发者ID:VishrutMehta,项目名称:indico,代码行数:16,代码来源:sessionDisplay.py

示例8: _process

    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")
开发者ID:MichelCordeiro,项目名称:indico,代码行数:19,代码来源:contribDisplay.py

示例9: _process

    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
开发者ID:vstitches,项目名称:indico,代码行数:20,代码来源:contribDisplay.py

示例10: schema

                    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)
开发者ID:jt1,项目名称:indico,代码行数:32,代码来源:handlers.py

示例11: schema

                    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)
开发者ID:Json-Andriopoulos,项目名称:indico,代码行数:32,代码来源:handlers.py

示例12: JSONSerializer

## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see <http://www.gnu.org/licenses/>.

"""
json-based fossil serializer
"""
# indico imports
from indico.util import json

# module imports
from indico.web.http_api.metadata.serializer import Serializer


class JSONSerializer(Serializer):

    """
    Does basically direct translation from the fossi
    """

    _mime = "application/json"

    def _execute(self, fossil):
        return json.dumps(fossil, pretty=self.pretty)


Serializer.register("json", JSONSerializer)
开发者ID:pferreir,项目名称:indico-backup,代码行数:30,代码来源:json.py

示例13: JSONSerializer

# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

"""
json-based fossil serializer
"""
# indico imports
from indico.util import json

# module imports
from indico.web.http_api.metadata.serializer import Serializer


class JSONSerializer(Serializer):

    """
    Does basically direct translation from the fossi
    """

    _mime = 'application/json'

    def _execute(self, fossil):
        return json.dumps(fossil, pretty=self.pretty)


Serializer.register('json', JSONSerializer)
开发者ID:OmeGak,项目名称:indico,代码行数:30,代码来源:json.py

示例14: isinstance

                            else:
                                subelem = etree.SubElement(elem, "item")
                                subelem.text = self._convert(subv)
                elif isinstance(v, dict):
                    elem.append(self._xmlForFossil(v))
                else:
                    txt = self._convert(v)
                    try:
                        elem.text = txt
                    except Exception:
                        Logger.get("xmlSerializer").exception(
                            "Setting XML text value failed (id: {}, value {!r})".format(id, txt)
                        )

        return felement

    def _execute(self, fossil, xml_declaration=True):
        if type(fossil) == list:
            # collection of fossils
            doc = etree.ElementTree(etree.Element("collection"))
            for elem in fossil:
                self._xmlForFossil(elem, doc)
            result = doc
        else:
            result = self._xmlForFossil(fossil)

        return etree.tostring(result, pretty_print=self.pretty, xml_declaration=xml_declaration, encoding="utf-8")


Serializer.register("xml", XMLSerializer)
开发者ID:pferreir,项目名称:indico-backup,代码行数:30,代码来源:xml.py

示例15: get_contribution_ical_file

def get_contribution_ical_file(contrib):
    data = {'results': serialize_contribution_for_ical(contrib)}
    serializer = Serializer.create('ics')
    return BytesIO(serializer(data))
开发者ID:DirkHoffmann,项目名称:indico,代码行数:4,代码来源:util.py


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