Esempio n. 1
0
 def setUp(self):
     metadata = Metadata()
     subdoc = subdocument(metadata, 'subdoc',
         Field('x', int))
     self.MyDoc = collection(
         metadata, 'mydoc',
         Field('y', subdoc, default=None))
Esempio n. 2
0
 def setUp(self):
     metadata = Metadata()
     subdoc = subdocument(metadata, "subdoc", Field("x", int))
     self.MyDoc = collection(
         metadata, "mydoc", Field("x", subdoc), Field("y", [subdoc])
     )
     self.doc = self.MyDoc.m.create(x=dict(x=5), y=[])
Esempio n. 3
0
 def test_can_make_schema(self):
     metadata = Metadata()
     subdoc = subdocument(metadata, 'subdoc',
         Field('x', int))
     self.MyDoc = collection(
         metadata, 'mydoc',
         Field('x', subdoc),
         Field('y', [subdoc]))
Esempio n. 4
0
 def setUp(self):
     metadata = Metadata()
     subdoc = subdocument(metadata, 'subdoc',
         Field('x', int))
     self.MyDoc = collection(
         metadata, 'mydoc',
         Field('x', subdoc),
         Field('y', [subdoc]))
     self.doc = self.MyDoc.m.create(x=dict(x=5), y=[])
Esempio n. 5
0
 def setUp(self):
     self.metadata = metadata.Metadata()
     self.Doc = subdocument(
         self.metadata, 'Doc',
         field.Field('x', int))
Esempio n. 6
0
import bson
from pymongo import ReturnDocument

import barin as b
import barin.schema as s

log = logging.getLogger(__name__)
metadata = b.Metadata()

# Message statuses: pending, ready, busy, error

_schedule = b.subdocument(
    metadata, '_schedule',
    b.Field('priority', int, default=10),
    b.Field('after', datetime, default=datetime.fromtimestamp(0)),
    b.Field('status', str, default='pending'),
    b.Field('message', str, default=''),
    b.Field('worker', str, default=None))


@b.cmap(b.collection(
    metadata, 'c2.message',
    b.Field('_id', s.ObjectId, default=bson.ObjectId),
    b.Field('s', metadata.cref('_schedule')),
    b.Field('task', str),
    b.Field('payload', {str: None})))
class Message(object):

    def __repr__(self):
        return '<Message {}: {}>'.format(self._id, self.task)
Esempio n. 7
0
 def test_can_make_schema(self):
     metadata = Metadata()
     subdoc = subdocument(metadata, "subdoc", Field("x", int))
     self.MyDoc = collection(
         metadata, "mydoc", Field("x", subdoc), Field("y", [subdoc])
     )
Esempio n. 8
0
 def setUp(self):
     metadata = Metadata()
     subdoc = subdocument(metadata, "subdoc", Field("x", int))
     self.MyDoc = collection(
         metadata, "mydoc", Field("y", subdoc, default=None)
     )
Esempio n. 9
0
 def setUp(self):
     self.metadata = metadata.Metadata()
     self.Doc = subdocument(self.metadata, 'Doc', field.Field('x', int))