当前位置: 首页>>代码示例>>Python>>正文


Python ming.collection函数代码示例

本文整理汇总了Python中ming.collection函数的典型用法代码示例。如果您正苦于以下问题:Python collection函数的具体用法?Python collection怎么用?Python collection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了collection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     self.MockSession = mock.Mock()
     self.MockSession.db = mock.MagicMock()
     self.TestDoc = collection(
         'test_doc', self.MockSession,
         Field('a', int, if_missing=None, index=True),
         Field('b', S.Object, if_missing=dict(a=S.Int(if_missing=None))))
     self.TestDocNoSchema = collection(
         'test_doc', self.MockSession)
开发者ID:terrasea,项目名称:ming,代码行数:9,代码来源:test_functional.py

示例2: test_index_inheritance_neither

    def test_index_inheritance_neither(self):
        NoIndexDoc = collection(
            'test123', self.MockSession,
            Field('_id', S.ObjectId),
            Field('test1', str),
            Field('test2', str),
            Field('test3', str))
        StillNone = collection(NoIndexDoc)

        self.assertEqual(list(StillNone.m.indexes), [])
开发者ID:terrasea,项目名称:ming,代码行数:10,代码来源:test_functional.py

示例3: setUp

 def setUp(self):
     self.MockSession = mock.Mock()
     self.MockSession.db = mock.MagicMock()
     self.Base = collection(
         "test_doc",
         self.MockSession,
         Field("type", str),
         Field("a", int),
         polymorphic_on="type",
         polymorphic_identity="base",
     )
     self.Derived = collection(self.Base, Field("b", int), polymorphic_identity="derived")
开发者ID:apendleton,项目名称:Ming,代码行数:12,代码来源:test_functional.py

示例4: test_index_inheritance_parent_none

    def test_index_inheritance_parent_none(self):
        NoIndexDoc = collection(
            "test123",
            self.MockSession,
            Field("_id", S.ObjectId),
            Field("test1", str),
            Field("test2", str),
            Field("test3", str),
        )
        AddSome = collection(NoIndexDoc, Index("foo"), Index("bar", unique=True))

        self.assertEqual(list(AddSome.m.indexes), [Index("foo"), Index("bar", unique=True)])
开发者ID:apendleton,项目名称:Ming,代码行数:12,代码来源:test_functional.py

示例5: test_index_inheritance_neither

    def test_index_inheritance_neither(self):
        NoIndexDoc = collection(
            "test123",
            self.MockSession,
            Field("_id", S.ObjectId),
            Field("test1", str),
            Field("test2", str),
            Field("test3", str),
        )
        StillNone = collection(NoIndexDoc)

        self.assertEqual(list(StillNone.m.indexes), [])
开发者ID:apendleton,项目名称:Ming,代码行数:12,代码来源:test_functional.py

示例6: test_index_inheritance_parent_none

    def test_index_inheritance_parent_none(self):
        NoIndexDoc = collection(
            'test123', self.MockSession,
            Field('_id', S.ObjectId),
            Field('test1', str),
            Field('test2', str),
            Field('test3', str))
        AddSome = collection(
            NoIndexDoc,
            Index('foo'),
            Index('bar', unique=True))

        self.assertEqual(list(AddSome.m.indexes),
                         [ Index('foo'), Index('bar', unique=True) ])
开发者ID:terrasea,项目名称:ming,代码行数:14,代码来源:test_functional.py

示例7: setUp

    def setUp(self):
        class IteratorMock(mock.Mock):
            def __init__(self, base_iter):
                super(IteratorMock, self).__init__()
                self._base_iter = base_iter
            def __iter__(self):
                return self
            def next(self):
                return next(self._base_iter)
            __next__ = next

        self.MockSession = mock.Mock()
        self.MockSession.db = mock.MagicMock()
        self.TestDoc = collection(
            'test_doc', self.MockSession,
            Field('a', int),
            Field('b', dict(a=int)))

        mongo_cursor = IteratorMock(iter([ {}, {}, {} ]))
        mongo_cursor.count = mock.Mock(return_value=3)
        mongo_cursor.limit = mock.Mock(return_value=mongo_cursor)
        mongo_cursor.hint = mock.Mock(return_value=mongo_cursor)
        mongo_cursor.skip = mock.Mock(return_value=mongo_cursor)
        mongo_cursor.sort = mock.Mock(return_value=mongo_cursor)
        self.cursor = Cursor(self.TestDoc, mongo_cursor)
开发者ID:vzhz,项目名称:function_generator,代码行数:25,代码来源:test_functional.py

示例8: test_enable_instrument

 def test_enable_instrument(self):
     session = Session(bind=self.datastore)
     basic1 = collection(
         'basic1', session,
         Field('_id', S.ObjectId),
         Field('a', int),
         Field('b', [int]),
         Field('c', dict(
                 d=int, e=int)))
     class Basic1(object):
         pass                    
     self.session.mapper(Basic1, basic1, options=dict(instrument=False))
     # Put a doc in the DB
     Basic1(a=1, b=[2,3], c=dict(d=4, e=5))
     self.session.flush()
     # Load back with instrumentation
     self.session.clear()
     obj = Basic1.query.find().options(instrument=True).first()
     self.assertEqual(type(obj.b), InstrumentedList)
     self.assertEqual(type(obj.c), InstrumentedObj)
     # Load back without instrumentation
     self.session.clear()
     obj = Basic1.query.find().options(instrument=False).first()
     self.assertEqual(type(obj.b), list)
     self.assertEqual(type(obj.c), Object)
开发者ID:duilio,项目名称:Ming,代码行数:25,代码来源:test_mapper.py

示例9: test_index_inheritance_both

    def test_index_inheritance_both(self):
        MyChild = collection(self.MyDoc, Index("test3"), Index("test4", unique=True), collection_name="my_child")
        MyGrandChild = collection(
            MyChild, Index("test5"), Index("test6", unique=True), collection_name="my_grand_child"
        )

        self.assertEqual(
            list(MyGrandChild.m.indexes),
            [
                Index("test1", unique=True),
                Index("test2"),
                Index(("test1", -1), ("test2", -1)),
                Index("test3"),
                Index("test4", unique=True),
                Index("test5"),
                Index("test6", unique=True),
            ],
        )
开发者ID:apendleton,项目名称:Ming,代码行数:18,代码来源:test_functional.py

示例10: setUp

 def setUp(self):
     self.datastore = create_datastore('mim:///test_db')
     session = Session(bind=self.datastore)
     self.session = ODMSession(session)
     basic = collection('basic', session)
     class Basic(object):
         pass                    
     self.session.mapper(Basic, basic)
     self.basic = basic
     self.Basic = Basic
开发者ID:duilio,项目名称:Ming,代码行数:10,代码来源:test_mapper.py

示例11: test_index_inheritance_both

    def test_index_inheritance_both(self):
        MyChild = collection(
            self.MyDoc,
            Index('test3'),
            Index('test4', unique=True),
            collection_name='my_child')
        MyGrandChild = collection(
            MyChild,
            Index('test5'),
            Index('test6', unique=True),
            collection_name='my_grand_child')

        self.assertEqual(
            list(MyGrandChild.m.indexes),
            [ Index('test1', unique=True),
              Index('test2'),
              Index(('test1', -1), ('test2', -1)),
              Index('test3'),
              Index('test4', unique=True),
              Index('test5'),
              Index('test6', unique=True) ])
开发者ID:terrasea,项目名称:ming,代码行数:21,代码来源:test_functional.py

示例12: commit

QSIZE = 100
README_RE = re.compile('^README(\.[^.]*)?$', re.IGNORECASE)
VIEWABLE_EXTENSIONS = ['.php','.py','.js','.java','.html','.htm','.yaml','.sh',
    '.rb','.phtml','.txt','.bat','.ps1','.xhtml','.css','.cfm','.jsp','.jspx',
    '.pl','.php4','.php3','.rhtml','.svg','.markdown','.json','.ini','.tcl','.vbs','.xsl']

DIFF_SIMILARITY_THRESHOLD = .5  # used for determining file renames

# Basic commit information
# One of these for each commit in the physical repo on disk. The _id is the
# hexsha of the commit (for Git and Hg).
CommitDoc = collection(
    'repo_ci', main_doc_session,
    Field('_id', str),
    Field('tree_id', str),
    Field('committed', SUser),
    Field('authored', SUser),
    Field('message', str),
    Field('parent_ids', [str], index=True),
    Field('child_ids', [str], index=True),
    Field('repo_ids', [ S.ObjectId() ], index=True))

# Basic tree information (also see TreesDoc)
TreeDoc = collection(
    'repo_tree', main_doc_session,
    Field('_id', str),
    Field('tree_ids', [dict(name=str, id=str)]),
    Field('blob_ids', [dict(name=str, id=str)]),
    Field('other_ids', [dict(name=str, id=str, type=SObjType)]))

# Information about the last commit to touch a tree/blob
# LastCommitDoc.object_id = TreeDoc._id
开发者ID:pombredanne,项目名称:SourceForge-Allura,代码行数:32,代码来源:repo.py

示例13: post

    def post(*args, **kwargs):
        return TaskObject.post(func, args, kwargs)
    func.post = post
    return func

TaskDoc = collection(
    'monq.task', doc_session,
    Field('_id', S.ObjectId),
    Field('state', S.OneOf(*STATES)),
    Field('priority', int),
    Field('result_type', S.OneOf(*RESULT_TYPES)),
    Field('time', dict(
            queue=S.DateTime(if_missing=datetime.utcnow),
            start=S.DateTime(if_missing=None),
            stop=S.DateTime(if_missing=None))),
    Field('task', dict(
            name=str,
            args=[None],
            kwargs={str:None})),
    Field('result', None, if_missing=None),
    Field('process', str),
    Index(
        ('state', 1),
        ('priority', -1),
        ('time.queue', 1)),
    Index('state', 'time_queue'))

class TaskObject(object):

    @LazyProperty
    def function(self):
开发者ID:rick446,项目名称:MonQ,代码行数:31,代码来源:model.py

示例14: test_index_inheritance_child_none

    def test_index_inheritance_child_none(self):
        MyChild = collection(self.MyDoc, collection_name='my_child')

        self.assertEqual(
            list(MyChild.m.indexes),
            list(self.MyDoc.m.indexes))
开发者ID:terrasea,项目名称:ming,代码行数:6,代码来源:test_functional.py

示例15: DataStore

__FILENAME__ = model
import ming
from ming.datastore import DataStore
from datetime import datetime

ds = DataStore('mongodb://localhost:27017', database='tutorial')
sess = ming.Session(ds)

Forum = ming.collection(
    'forum.forum', sess, 
    ming.Field('_id', ming.schema.ObjectId),
    ming.Field('name', str),
    ming.Field('description', str),
    ming.Field('created', datetime, if_missing=datetime.utcnow),
    ming.Field('last_post', dict(
        when=datetime,
        user=str,
        subject=str)),
    ming.Field('num_threads', int),
    ming.Field('num_posts', int))

Thread = ming.collection(
    'forum.thread', sess,
    ming.Field('_id', ming.schema.ObjectId),
    ming.Field(
        'forum_id', ming.schema.ObjectId(if_missing=None),
        index=True),
    ming.Field('subject', str),
    ming.Field('last_post', dict(
        when=datetime,
        user=str,
开发者ID:Mondego,项目名称:pyreco,代码行数:31,代码来源:allPythonContent.py


注:本文中的ming.collection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。