Exemple #1
0
 def create(cls, args):
     args['_id'] = args.pop('id')
     utils.update(args, cls.attrs)
     try:
         cls.get_collection().insert(args)
     except pymongo.errors.DuplicateKeyError as e:
         cls.abort_exists()
     return cls(args['_id'])
Exemple #2
0
 def create(cls, args):
     args['_id'] = args.pop('id')
     utils.update(args, cls.attrs)
     try:
         cls.get_collection().insert(args)
     except pymongo.errors.DuplicateKeyError as e:
         cls.abort_exists()
     return cls(args['_id'])
Exemple #3
0
def test_update():
    d = {
        'foo': 1,
        'bar': 2,
        'fubar': {
            'a': 1
        }
    }

    utils.update(d, {
        'bar': 3,
        'foobar': 4,
        'fubar': {
            'a': 5
        }
    })

    eq_(d, {
        'foo': 1,
        'bar': 3,
        'foobar': 4,
        'fubar': {
            'a': 5
        }})
Exemple #4
0
def test_update():
    d = {'foo': 1, 'bar': 2, 'fubar': {'a': 1}}

    utils.update(d, {'bar': 3, 'foobar': 4, 'fubar': {'a': 5}})

    eq_(d, {'foo': 1, 'bar': 3, 'foobar': 4, 'fubar': {'a': 5}})