示例#1
0
class CheckList(Check):
    object_type = 'list'

    parent = fields.NodeID()
    tags = fields.Set(fields.String())
    pos_filter = fields.Object(PosFilter)
    nodes = fields.Set(fields.NodeID())
示例#2
0
 def test_set(self):
     a = fields.Set(fields.Object(Piwo))
     a.validate(set())
     a.validate({Piwo()})
     with self.assertRaises(SchemaError):
         a.validate(Piwo())
     with self.assertRaises(SchemaError):
         a.validate([])
     with self.assertRaises(SchemaError):
         a.validate(None)
     with self.assertRaises(SchemaError):
         a.validate({Piwo(), Zlew()})
     with self.assertRaises(SchemaError):
         a.validate({Piwo(), None})
     self.assertEqual(a.load([]), set())
     self.assertEqual(a.load(['piwo']), {Piwo()})
     with self.assertRaises(SchemaError):
         a.validate(a.load({}))
     with self.assertRaises(SchemaError):
         a.validate(a.load(None))
     with self.assertRaises(SchemaError):
         a.validate(a.load('piwo'))
     with self.assertRaises(SchemaError):
         a.validate(a.load(['zlew']))
     with self.assertRaises(SchemaError):
         a.validate(a.load(['piwo', None]))
     self.assertEqual(a.dump({}), [])
     self.assertEqual(a.dump({Piwo()}), ['piwo'])
     fields.Set(fields.Integer(), default={1, 2, 3})
示例#3
0
class Node(model.Model):
    """
    Stores the lightweight data associated with a node, and an index of heavy
    data (which has to be downloaded separately).  This includes:

    - ``id``: self-descriptive.  The ID of a node cannot be changed.
    - ``parent``: the node parent's ID.
    - ``pos_start`` and ``pos_end``: for nodes where it makes sense (mostly
      chunka), the range of positions occupied by this object.  ``pos_start``
      is inclusive, while ``pos_end`` is exclusive.
    - ``tags``: an unordered set of tags, which are simple strings.
    - ``attr``: a string-keyed dict of attributes with arbitrary data.
    - ``data``: an unordered set of keys with non-null heavyweight data.
      The data has to be downloaded separately.
    - ``bindata``: a dict with an index of available bindata.  The keys in
      this dict correspond to bindata keys, and the values are size of the
      corresponding binary data in bytes.  The actual bindata has to
      be downloaded separately.
    - ``triggers``: a dict containing active triggers for the given node.
      The keys are trigger names, and they are mapped to the state of
      the given trigger.
    """

    id = fields.NodeID()
    parent = fields.NodeID(default=NodeID.root_id)
    pos_start = fields.Integer(optional=True)
    pos_end = fields.Integer(optional=True)
    tags = fields.Set(fields.String())
    attr = fields.Map(fields.String(), fields.Any())
    data = fields.Set(fields.String())
    bindata = fields.Map(fields.String(), fields.SmallUnsignedInteger())
    triggers = fields.Map(fields.String(), fields.Enum(TriggerState))
示例#4
0
文件: operation.py 项目: NYStud/veles
class OperationCreate(Operation):
    object_type = 'create'

    parent = fields.NodeID(default=NodeID.root_id)
    pos_start = fields.Integer(optional=True)
    pos_end = fields.Integer(optional=True)
    tags = fields.Set(fields.String())
    attr = fields.Map(fields.String(), fields.Any())
    data = fields.Map(fields.String(), fields.Any())
    bindata = fields.Map(fields.String(), fields.Binary())
    triggers = fields.Set(fields.String())
示例#5
0
class MsgGetList(MsgpackMsg):
    """
    Sent by client, requests a list of children of the given node matching
    the given filters.  Children can be filtered by tags (the set of tags
    in the query must be a subset of the node's tags for it to match)
    and by a position filter.

    If sub is False, server will reply with a single MsgGetListReply with
    gone=[], or with a single MsgQueryError.  If sub is True, the first
    reply will be like for sub=False, but subsequent replies will only
    mention changed nodes - nodes that are new on the list, along with
    changed nodes remaining on the list are sent in the objs field
    of the reply, while the IDs of nodes no longer on the list are sent
    in the gone field of the reply.

    The list may fail with ObjectGoneError if the parent node is gone.
    If it reappears in the future, a MsgGetListReply will be sent
    with a complete list of children.
    """

    object_type = 'get_list'

    qid = fields.SmallUnsignedInteger()
    parent = fields.NodeID(default=NodeID.root_id)
    tags = fields.Set(fields.String())
    pos_filter = fields.Object(PosFilter, default=PosFilter())
    sub = fields.Boolean(default=False)
示例#6
0
class MsgCreate(MsgpackMsg):
    """
    Creates a node on the server.  It is an error if a node with given id
    already exists.  Server replies with MsgRequestAck or MsgRequestError.
    Replies are matched to requests by ``rid``, which is assigned by the
    client.
    """

    object_type = 'create'

    rid = fields.SmallUnsignedInteger()
    id = fields.NodeID()
    parent = fields.NodeID(default=NodeID.root_id)
    pos_start = fields.Integer(optional=True)
    pos_end = fields.Integer(optional=True)
    tags = fields.Set(fields.String())
    attr = fields.Map(fields.String(), fields.Any())
    data = fields.Map(fields.String(), fields.Any())
    bindata = fields.Map(fields.String(), fields.Binary())
    triggers = fields.Set(fields.String())
示例#7
0
class MsgPluginTriggerRegister(MsgpackMsg):
    """
    Sent by the client to register a trigger handler.  Has no reply.
    ``phid`` is an arbitrary number chosen by the client to identify this
    method handler.
    """

    object_type = 'plugin_trigger_register'

    phid = fields.SmallUnsignedInteger()
    name = fields.String()
    tags = fields.Set(fields.String())
示例#8
0
class CheckTags(Check):
    object_type = 'tags'

    node = fields.NodeID()
    tags = fields.Set(fields.String())
示例#9
0
class SetOptional(model.Model):
    a = fields.Set(fields.SmallInteger(), optional=True, default=None)
示例#10
0
class Set(model.Model):
    a = fields.Set(fields.SmallInteger())
示例#11
0
class TurboZlew(Zlew):
    c = fields.Set(fields.Binary())
    d = fields.Object(Piwo)
    e = fields.Integer(default=3)