2 - Bag from/to source

As we have seen in the previous chapter, a Bag is a completely dynamic structure. A Bag has a polymorphic interaction with many complex data sources, so it's possible to fill it passing

  • A string representing an XML section
  • A file path of an XML file
  • An URI of a remore XML file
  • A file path of a directory on local disk
  • A pickle file
  • A Bag
fromlocal= Bag('%s/test_files/standardxml.xml' %current)
fromurl= Bag('http://www.plone.org')
fromdirectory= Bag('%s/test_files' %current)

stringxml='<?xml version="1.02" encoding="UTF-8"?><a><b name="fuffy"><d>dog</d></b><c/></a>'
        
fromstringxml=Bag(stringxml)

A bag can also be serialized into different formats:

  • XML
  • pickle
  • JSON
  • etc.

In the following chapters we'll examine how to load and convert bags in many formats.


Error: Failed to load processor FooterNavLinks
No macro or processor named 'FooterNavLinks' found

Attachments