• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ming.collection函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: collection

from ming.utils import LazyProperty

from .m_base import ModelBase, CookbookFile
from .m_session import doc_session, orm_session

log = logging.getLogger(__name__)

cookbook_version = collection(
    'chef.cookbook_version', doc_session,
    Field('_id', S.ObjectId()),
    Field('account_id', S.ObjectId(if_missing=None)),
    Field('name', str),
    Field('version', str),
    Field('cookbook_name', str),
    Field('metadata', S.Anything(if_missing={})),
    Field('definitions', [ CookbookFile ]),
    Field('attributes', [ CookbookFile ]),
    Field('files', [ CookbookFile ]),
    Field('providers', [ CookbookFile ]),
    Field('resources', [ CookbookFile ]),
    Field('templates', [ CookbookFile ]),
    Field('recipes', [ CookbookFile ]),
    Field('root_files', [ CookbookFile ]),
    Field('libraries', [ CookbookFile ]),
    Index('account_id', 'cookbook_name', 'version', unique=True))

class CookbookVersion(ModelBase):

    @property
    def __name__(self):
        return self.version
开发者ID:rick446,项目名称:MongoPyChef,代码行数:31,代码来源:m_cookbook.py


示例17: collection

from ming import collection, Field
from ming.fs import filesystem
from ming import schema as S
from ming.orm import RelationProperty, ForeignIdProperty

from .m_base import ModelBase
from .m_session import doc_session, orm_session
from ..lib.util import cnonce

log = logging.getLogger(__name__)

sandbox = collection(
    "chef.sandbox",
    doc_session,
    Field("_id", str, if_missing=cnonce),
    Field("account_id", S.ObjectId(if_missing=None)),
    Field("checksums", [str]),
)

chef_file = filesystem(
    "chef.file",
    doc_session,
    Field("_id", str),  # account_id-md5
    Field("account_id", S.ObjectId(if_missing=None)),
    Field("needs_upload", bool, if_missing=True),
)


class Sandbox(ModelBase):
    @property
开发者ID:rick446,项目名称:MongoPyChef,代码行数:30,代码来源:m_sandbox.py


示例18: collection

import bson
import json
import logging

from ming import collection, Field, Index, Session
from ming import schema as S

from pwcred import security

doc_session = Session.by_name('pwcred')

log = logging.getLogger(__name__)

client = collection(
    'pwcred.client', doc_session,
    Field('_id', str),
    Field('ip_addrs', [ str ]),
    Field('context', str),
    Field('public_key', str))

credentials = collection(
    'pwcred.credentials', doc_session,
    Field('_id', S.ObjectId()),
    Field('key', str),
    Field('client_id', str),
    Field('enc_aes_key', S.Binary()),
    Field('aes_iv', S.Binary()),
    Field('enc_creds', S.Binary()),
    Index('client_id', 'key', unique=True))

def encrypt_credentials(client, key, **creds):
    plaintext = security.pad(json.dumps(credentials))
开发者ID:synappio,项目名称:pwcred,代码行数:32,代码来源:model.py


示例19: commit

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']
PYPELINE_EXTENSIONS = utils.MARKDOWN_EXTENSIONS + ['.rst']

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
LastCommitDoc = collection(
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:32,代码来源:repo.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ming.configure函数代码示例发布时间:2022-05-27
下一篇:
Python minesweeper.board函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap