Package s3 :: Module s3codec :: Class S3Codec
[frames] | no frames]

Class S3Codec

source code

object --+
         |
        S3Codec

Base class for converting S3Resources into/from external data formats, for use with S3Importer/S3Exporter

Instance Methods
 
encode(self, resource, **attr)
API Method to encode a resource in the target format, to be implemented by the subclass (mandatory)
source code
 
decode(self, resource, source, **attr)
API Method to decode a source into an S3XML ElementTree, to be implemented by the subclass (if the class does decode)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
get_codec(cls, fmt)
Get a codec by representation format
source code
 
xml_encode(cls, s)
XML-escape a string
source code
 
xml_decode(cls, s)
XML-unescape a string
source code
Static Methods
 
crud_string(tablename, name)
Get a CRUD string
source code
 
json_message(success=True, statuscode=None, message=None, **kwargs)
Provide a nicely-formatted JSON Message
source code
Class Variables
  indices = ["id", "pe_id", "site_id", "sit_id", "item_entity_id"]
  CODECS = {"pdf": "S3RL_PDF", "shp": "S3SHP", "svg": "S3SVG", "...
  PY2XML = {"'": "'", '"': """}
  XML2PY = {"'": "'", """: '"'}
Properties

Inherited from object: __class__

Method Details

get_codec(cls, fmt)
Class Method

source code 

Get a codec by representation format

Parameters:
  • fmt - the representation format (string)

encode(self, resource, **attr)

source code 

API Method to encode a resource in the target format, to be implemented by the subclass (mandatory)

Parameters:
  • resource - the S3Resource
Returns:
a handle to the output

decode(self, resource, source, **attr)

source code 

API Method to decode a source into an S3XML ElementTree, to be implemented by the subclass (if the class does decode)

Parameters:
  • resource - the S3Resource
  • source - the source
Returns:
an S3XML ElementTree

xml_encode(cls, s)
Class Method

source code 

XML-escape a string

Parameters:
  • s - the string

xml_decode(cls, s)
Class Method

source code 

XML-unescape a string

Parameters:
  • s - the string

crud_string(tablename, name)
Static Method

source code 

Get a CRUD string

Parameters:
  • tablename - the table name
  • name - the name of the CRUD string

json_message(success=True, statuscode=None, message=None, **kwargs)
Static Method

source code 

Provide a nicely-formatted JSON Message

Parameters:
  • success - action succeeded or failed
  • status_code - the HTTP status code
  • message - the message text
  • kwargs - other elements for the message
  • tree - error tree to include as JSON object (rather than as string) for easy decoding

Class Variable Details

indices

Value:
["id", "pe_id", "site_id", "sit_id", "item_entity_id"]

CODECS

Value:
{"pdf": "S3RL_PDF", "shp": "S3SHP", "svg": "S3SVG", "xls": "S3XLS", "c\
ard": "S3PDFCard",}

PY2XML

Value:
{"'": "'", '"': """}

XML2PY

Value:
{"'": "'", """: '"'}