gavo.rscdef.mixins module

Resource mixins.

class gavo.rscdef.mixins.LateEvents(*args, **kwargs)[source]

Bases: EmbeddedStream

An event stream played back by a mixin when the substrate is being finalised (but before the early processing).

attrSeq = [<gavo.base.complexattrs.StructAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.attrdef.ActionAttribute object>]
completedCallbacks = []
managedAttrs = {'DEFAULTS': <gavo.base.complexattrs.StructAttribute object>, 'doc': <gavo.base.attrdef.UnicodeAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'passivate': <gavo.base.attrdef.ActionAttribute object>}
name_ = 'lateEvents'
class gavo.rscdef.mixins.MixinAttribute(**kwargs)[source]

Bases: SetOfAtomsAttribute

An attribute defining a mixin.

This currently is only offered on tables, though in principle we could have it anywhere now, but we’d want some compatibility checking then.

This is never copyable since this would meaning playing the same stuff into an object twice.

This means trouble for magic scripts (in particular processLate); e.g., if you copy a table mixing in products, the data element for that table will not receive the product table. Goes to show the whole product mess is ugly and needs a good idea.

create(parent, ctx, name)[source]
feed(ctx, instance, mixinRef, fillers={})[source]

feeds the immediate elements and schedules the rest of actions to be taken in time.

iterParentMethods()[source]

returns an iterator over (name, method) pairs that should be inserted in the parent class.

makeUserDoc()[source]
class gavo.rscdef.mixins.MixinDef(parent, **kwargs)[source]

Bases: ReplayBase

A definition for a resource mixin.

Resource mixins are resource descriptor fragments typically rooted in tables (though it’s conceivable that other structures could grow mixin attributes as well).

They are used to define and implement certain behaviours components of the DC software want to see:

  • products want to be added into their table, and certain fields are required

    within tables describing products

  • tables containing positions need some basic machinery to support scs.

  • siap needs quite a bunch of fields

Mixins consist of events that are played back on the structure mixing in before anything else happens (much like original) and two procedure definitions, viz, processEarly and processLate. These can access the structure that has the mixin as substrate.

processEarly is called at the lexical location of the mixin. processLate is executed just before the parser exits. This is the place to fix up anything that uses the table mixed in. Note, however, that you should be as conservative as possible here – you should think of DC structures as immutable as long as possible.

Programmatically, you can check if a certain table mixes in something by calling its mixesIn method.

Recursive application of mixins, even to separate objects, will deadlock.

applyTo(destination, ctx, fillers={})[source]

replays the stored events on destination and arranges for processEarly and processLate to be run.

applyToFinished(destination)[source]

applies the mixin to an object already parsed.

Late callbacks will only be executed if destination has an rd attribute; if that is the case, this rd’s idmap will be amended with anything the mixin comes up with.

attrSeq = [<gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.complexattrs.UniquedStructListAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.attrdef.BooleanAttribute object>, <gavo.base.parsecontext.ReferenceAttribute object>]
completeElement(ctx)[source]
completedCallbacks = []
execMacro(macName, args)[source]
managedAttrs = {'EDIT': <gavo.base.complexattrs.StructListAttribute object>, 'PRUNE': <gavo.base.complexattrs.StructListAttribute object>, 'doc': <gavo.base.attrdef.UnicodeAttribute object>, 'edits': <gavo.base.complexattrs.StructListAttribute object>, 'events': <gavo.base.complexattrs.StructAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'lateEvents': <gavo.base.complexattrs.StructAttribute object>, 'mixinPar': <gavo.base.complexattrs.UniquedStructListAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'pars': <gavo.base.complexattrs.UniquedStructListAttribute object>, 'processEarly': <gavo.base.complexattrs.StructAttribute object>, 'processLate': <gavo.base.complexattrs.StructAttribute object>, 'prunes': <gavo.base.complexattrs.StructListAttribute object>, 'reexpand': <gavo.base.attrdef.BooleanAttribute object>, 'source': <gavo.base.parsecontext.ReferenceAttribute object>}
name_ = 'mixinDef'
class gavo.rscdef.mixins.MixinPar(parent, **kwargs)[source]

Bases: AliasableRDParameter

A parameter definition for mixins.

The (optional) body provides a default for the parameter.

attrSeq = [<gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.NWUnicodeAttribute object>, <gavo.base.structure.DataContent object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.attrdef.BooleanAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>]
completedCallbacks = []
managedAttrs = {'alias': <gavo.base.attrdef.UnicodeAttribute object>, 'content_': <gavo.base.structure.DataContent object>, 'description': <gavo.base.attrdef.NWUnicodeAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'key': <gavo.base.attrdef.UnicodeAttribute object>, 'late': <gavo.base.attrdef.BooleanAttribute object>, 'name': <gavo.base.attrdef.UnicodeAttribute object>}
name_ = 'mixinPar'
validate()[source]
class gavo.rscdef.mixins.ProcessEarly(parent, **kwargs)[source]

Bases: ProcApp

A code fragment run by the mixin machinery when the structure being worked on is being finished.

Within processEarly, you can access:

  • the structure the mixin is applied to as “substrate”

  • the mixin parameters as “mixinPars”

  • the parse context as “context”

(the context is particularly handy for context.resolveId)

attrSeq = [<gavo.base.complexattrs.StructListAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.parsecontext.ReferenceAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.attrdef.EnumeratedUnicodeAttribute object>]
completedCallbacks = []
formalArgs = 'context, substrate, mixinPars'
managedAttrs = {'bind': <gavo.base.complexattrs.StructListAttribute object>, 'bindings': <gavo.base.complexattrs.StructListAttribute object>, 'code': <gavo.base.attrdef.UnicodeAttribute object>, 'deprecated': <gavo.base.attrdef.UnicodeAttribute object>, 'doc': <gavo.base.attrdef.UnicodeAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'name': <gavo.base.attrdef.UnicodeAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'procDef': <gavo.base.parsecontext.ReferenceAttribute object>, 'setup': <gavo.base.complexattrs.StructListAttribute object>, 'setups': <gavo.base.complexattrs.StructListAttribute object>, 'type': <gavo.base.attrdef.EnumeratedUnicodeAttribute object>}
name_ = 'processEarly'
class gavo.rscdef.mixins.ProcessLate(parent, **kwargs)[source]

Bases: ProcApp

A code fragment run by the mixin machinery when the parser parsing everything exits.

Within processLate, you can access:

  • the structure mixed in as “substrate”,

  • the root structure of the whole parse tree as root,

  • the parse context as “context”,

  • and the mixin parameters (a dictionary) as “mixinPars”.

attrSeq = [<gavo.base.complexattrs.StructListAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.parsecontext.ReferenceAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.attrdef.EnumeratedUnicodeAttribute object>]
completedCallbacks = []
formalArgs = 'substrate, root, context, mixinPars'
managedAttrs = {'bind': <gavo.base.complexattrs.StructListAttribute object>, 'bindings': <gavo.base.complexattrs.StructListAttribute object>, 'code': <gavo.base.attrdef.UnicodeAttribute object>, 'deprecated': <gavo.base.attrdef.UnicodeAttribute object>, 'doc': <gavo.base.attrdef.UnicodeAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'name': <gavo.base.attrdef.UnicodeAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'procDef': <gavo.base.parsecontext.ReferenceAttribute object>, 'setup': <gavo.base.complexattrs.StructListAttribute object>, 'setups': <gavo.base.complexattrs.StructListAttribute object>, 'type': <gavo.base.attrdef.EnumeratedUnicodeAttribute object>}
name_ = 'processLate'