shoop.core.fields package

Submodules

shoop.core.fields.tagged_json module

“Tagged JSON” encoder/decoder.

Objects that are normally not unambiguously representable via JSON are encoded into special objects of the form {tag: val}; the encoding and decoding process can be customized however necessary.

shoop.core.fields.tagged_json.isoformat(obj)[source]
shoop.core.fields.tagged_json.encode_enum(enum_val)[source]
shoop.core.fields.tagged_json.decode_enum(val)[source]
class shoop.core.fields.tagged_json.TagRegistry[source]

Bases: object

register(tag, classes, encoder=<class 'str'>, decoder=None)[source]
encode(obj, default)[source]
decode(obj)[source]
shoop.core.fields.tagged_json.tag_registry = <shoop.core.fields.tagged_json.TagRegistry object>

The default tag registry.

class shoop.core.fields.tagged_json.TaggedJSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: jsonfield.encoder.JSONEncoder

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (‘, ‘, ‘: ‘) if indent is None and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.

If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

registry = <shoop.core.fields.tagged_json.TagRegistry object>
default(obj)[source]

Module contents

class shoop.core.fields.InternalIdentifierField(**kwargs)[source]

Bases: django.db.models.fields.CharField

get_prep_value(value)[source]
deconstruct()[source]
class shoop.core.fields.CurrencyField(**kwargs)[source]

Bases: django.db.models.fields.CharField

class shoop.core.fields.FormattedDecimalFormField(max_value=None, min_value=None, max_digits=None, decimal_places=None, *args, **kwargs)[source]

Bases: django.forms.fields.DecimalField

MAX_DECIMAL_PLACES_FOR_STEP = 5
widget_attrs(widget)[source]
class shoop.core.fields.FormattedDecimalField(verbose_name=None, name=None, max_digits=None, decimal_places=None, **kwargs)[source]

Bases: django.db.models.fields.DecimalField

DecimalField subclass to display decimal values in non-scientific format.

value_from_object(obj)[source]
format_decimal(value, max_digits=100, exponent_limit=100)[source]
formfield(**kwargs)[source]
class shoop.core.fields.MoneyValueField(**kwargs)[source]

Bases: shoop.core.fields.FormattedDecimalField

class shoop.core.fields.QuantityField(**kwargs)[source]

Bases: shoop.core.fields.FormattedDecimalField

class shoop.core.fields.MeasurementField(unit, **kwargs)[source]

Bases: shoop.core.fields.FormattedDecimalField

KNOWN_UNITS = ('mm', 'm', 'kg', 'g', 'm3')
deconstruct()[source]
class shoop.core.fields.LanguageField(*args, **kwargs)[source]

Bases: django.db.models.fields.CharField

LANGUAGE_CODES = {'trv', 'ro_MD', 'nso', 'krj', 'kk', 'my', 'th', 'tkl', 'ase', 'gba', 'uz', 'shu', 'dyu', 'ain', 'gbz', 'non', 'lmo', 'shn', 'ie', 'wal', 'cgg', 'pdt', 'ae', 'byn', 'vot', 'gu', 'nan', 'tg', 'za', 'xog', 'teo', 'zxx', 'chk', 'es_419', 'lun', 'ter', 'fon', 'en', 'sk', 've', 'tli', 'ach', 'anp', 'ba', 'hu', 'mwv', 'bho', 'zza', 'hy', 'nmg', 'ms', 'mag', 'sq', 'doi', 'bug', 'ks', 'wa', 'tiv', 'bm', 'la', 'kaw', 'lu', 'dsb', 'ksf', 'pt', 'rn', 'mdr', 'ang', 'ga', 'nv', 'ku', 'eo', 'zea', 'gur', 'bax', 'es_MX', 'jgo', 'or', 'sbp', 'ksh', 'kl', 'syc', 'kpe', 'gag', 'ln', 'kri', 'eka', 'ar', 'kv', 'tzm', 'rm', 'akz', 'te', 'kaa', 'hak', 'ibb', 'bar', 'ttt', 'cch', 'nn', 'mde', 'pl', 'kok', 'elx', 'tly', 'kru', 'lzz', 'lfn', 'twq', 'yo', 'mul', 'ha', 'lez', 'sma', 'crh', 'hsn', 'ny', 'new', 'id', 'chb', 'krl', 'sl', 'tet', 'saz', 'akk', 'nus', 'brx', 'prg', 'nyo', 'tvl', 'sw', 'iba', 'yrl', 'syr', 'nov', 'gan', 'bbc', 'nym', 'jmc', 'ts', 'cv', 'en_CA', 'dar', 'az', 'mh', 'si', 'dav', 'pam', 'ab', 'bra', 'tmh', 'os', 'zun', 'awa', 'cu', 'kbl', 'ebu', 'zh_Hans', 'ne', 'dtp', 'be', 'pap', 'sid', 'st', 'so', 'avk', 'he', 'wae', 'fr', 'sco', 'gil', 'it', 'kaj', 'tsd', 'br', 'bez', 'aa', 'kbd', 'bpy', 'an', 'zen', 'cop', 'kj', 'rap', 'sr', 'swb', 'ar_001', 'af', 'mos', 'mzn', 'nb', 'ko', 'cr', 'lah', 'tl', 'mua', 'sa', 'lol', 'ho', 'lb', 'saq', 'ext', 'umb', 'lad', 'egl', 'vls', 'mga', 'bfd', 'nap', 'arq', 'sly', 'esu', 'bew', 'jut', 'byv', 'hsb', 'fro', 'na', 'mic', 'tog', 'lam', 'ale', 'pt_BR', 'ii', 'ty', 'mgh', 'dzg', 'ken', 'und', 'ceb', 'brh', 'de', 'mye', 'hz', 'sh', 'ce', 'ss', 'tsi', 'ig', 'sei', 'ug', 'rgn', 'got', 'mai', 'bla', 'cy', 'sga', 'rw', 'ee', 'fo', 'kn', 'cs', 'maf', 'gaa', 'tem', 'guz', 'bg', 'myv', 'ak', 'ia', 'sg', 'ro', 'udm', 'tum', 'bem', 'kab', 'fr_CH', 'ff', 'no', 'vi', 'tk', 'scn', 'khw', 'io', 'zbl', 'rug', 'frc', 'es_ES', 'grc', 'khq', 'ilo', 'fan', 'pcd', 'mer', 'sdc', 'mak', 'kln', 'bss', 'pro', 'ban', 'tru', 'gd', 'inh', 'en_AU', 'sc', 'vep', 'xh', 'nyn', 'sv', 'mr', 'kos', 'ca', 'wbp', 'pnt', 'gl', 'srr', 'gsw', 'de_CH', 'ki', 'ml', 'to', 'liv', 'ja', 'rtm', 'cps', 'xal', 'nnh', 'nia', 'mni', 'men', 'av', 'sgs', 'pag', 'ary', 'zh', 'uk', 'se', 'luo', 'bs', 'jv', 'arn', 'lzh', 'sus', 'nl_BE', 'es', 'mg', 'jpr', 'dgr', 'tyv', 'ik', 'csb', 'sog', 'dv', 'sba', 'bi', 'ka', 'ssy', 'ksb', 'war', 'jrb', 'pdc', 'stq', 'nzi', 'del', 'gwi', 'din', 'kut', 'ht', 'bgn', 'sms', 'aln', 'dje', 'was', 'gon', 'bn', 'moh', 'alt', 'sah', 'mad', 'chp', 'sm', 'kea', 'bfq', 'chy', 'bua', 'zu', 'krc', 'zap', 'iu', 'mdf', 'dua', 'bbj', 'grb', 'kw', 'zh_Hant', 'yi', 'wo', 'arc', 'bas', 'hif', 'frr', 'frp', 'pau', 'nog', 'en_US', 'rif', 'pi', 'lui', 'nd', 'cho', 'lo', 'ti', 'ay', 'et', 'mk', 'niu', 'kkj', 'bin', 'kcg', 'rom', 'gmh', 'mnc', 'chm', 'nr', 'eu', 'car', 'tr', 'hit', 'swc', 'rar', 'kgp', 'pal', 'tkr', 'smj', 'lij', 'qu', 'aro', 'tt', 'sas', 'li', 'aeb', 'de_AT', 'seh', 'dyo', 'am', 'fit', 'fa_AF', 'ada', 'en_GB', 'ta', 'afh', 'mi', 'mn', 'zgh', 'gay', 'sad', 'bej', 'kam', 'fy', 'cay', 'gv', 'snk', 'sam', 'suk', 'vmf', 'naq', 'cad', 'lua', 'hi', 'bal', 'vun', 'pms', 'rwk', 'hai', 'pa', 'bum', 'frs', 'frm', 'lrc', 'nl', 'mfe', 'lus', 'yue', 'bqi', 'dum', 'hr', 'dz', 'bjn', 'loz', 'co', 'fur', 'mus', 'efi', 'el', 'oj', 'fil', 'kde', 'quc', 'kha', 'njo', 'yao', 'fat', 'fi', 'ota', 'ng', 'ky', 'ur', 'fa', 'vro', 'oc', 'ady', 'ses', 'koi', 'arw', 'luy', 'mwl', 'pon', 'ast', 'bik', 'gor', 'hil', 'ch', 'guc', 'goh', 'tcy', 'yav', 'xmf', 'uga', 'ckb', 'nds_NL', 'kho', 'ewo', 'lt', 'mas', 'man', 'chg', 'ltg', 'lg', 'kiu', 'gom', 'om', 'vec', 'mt', 'phn', 'smn', 'sux', 'ace', 'vai', 'root', 'lag', 'tw', 'den', 'ru', 'kfo', 'fr_CA', 'osa', 'chr', 'jbo', 'tn', 'agq', 'nqo', 'shi', 'gez', 'asa', 'sli', 'pfl', 'glk', 'hmn', 'arz', 'su', 'sat', 'jam', 'srn', 'rof', 'da', 'rue', 'kac', 'tpi', 'szl', 'tig', 'nwc', 'see', 'pt_PT', 'dak', 'sdh', 'lv', 'kmb', 'sn', 'vo', 'mgo', 'sel', 'km', 'peo', 'chn', 'fj', 'bkm', 'izh', 'as', 'arp', 'mwr', 'tlh', 'egy', 'rup', 'wuu', 'raj', 'lkt', 'gn', 'bo', 'nds', 'sd', 'haw', 'yap', 'enm', 'kr', 'mrj', 'kg', 'qug', 'is', 'kum', 'ps', 'ybb', 'min', 'hup'}
get_choices(include_blank=True, blank_choice=[('', '---------')])[source]
class shoop.core.fields.UnsavedForeignKey(to, to_field=None, rel_class=<class 'django.db.models.fields.related.ManyToOneRel'>, db_constraint=True, **kwargs)[source]

Bases: django.db.models.fields.related.ForeignKey

allow_unsaved_instance_assignment = True
class shoop.core.fields.TaggedJSONField(*args, **kwargs)[source]

Bases: jsonfield.fields.JSONField

contribute_to_class(cls, name)