How to use the ming.Field function in Ming

To help you get started, we’ve selected a few Ming examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rick446 / MongoPyChef / mongopychef / model / m_role.py View on Github external
import logging
from json import loads, dumps

from ming import collection, Field, Index
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

log = logging.getLogger(__name__)

role = collection(
    'chef.role', doc_session,
    Field('_id', S.ObjectId()),
    Field('account_id', S.ObjectId(if_missing=None)),
    Field('name', str),
    Field('description', str),
    Field('default_attributes', str, if_missing='{}'),
    Field('override_attributes', str, if_missing='{}'),
    Field('run_list', [ str ] ),
    Field('env_run_lists', { str: [ str ]}),
    Index('account_id', 'name', unique=True))

class Role(ModelBase):

    @property
    def __name__(self):
        return self.name

    def __json__(self):
github apache / allura / Allura / allura / model / repository.py View on Github external
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
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(
    'repo_last_commit', main_doc_session,
    Field('_id', S.ObjectId()),
    Field('commit_id', str),
    Field('path', str),
    Index('commit_id', 'path'),
    Field('entries', [dict(
        name=str,
        commit_id=str)]))


class RepoObject(object):
github TurboGears / Ming / benchmarks / validation.py View on Github external
slice(0, 5), slice(-5, -1))
            ))
    download_page=Field(str)
    screenshot_page=Field(str)
    maintainers=Field([_person])
    developers=Field([_person])
    file_feed=Field(str)
    awards=Field([ dict(category=str, url=str, event=str, img_url=str) ])
    sf_piwik_siteid=Field(str)
    license=Field(S.Deprecated())
    license_uri=Field(str)
    license_title=Field(str)
    developer_page=Field(str)

    test_foo2=Field(S.Deprecated)
    fossforus_id=Field(S.Deprecated)
    fossforus_screenshots=Field(S.Deprecated)
    fossforus_features=Field(S.Deprecated)
    fossforus_tags=Field(S.Deprecated)
    fossforus_ratings=Field(S.Deprecated)
    _last_snapshot_id=Field(S.Deprecated)

print 'Begin test'
sys.stdout.flush()
begin = time.time()
for x in xrange(NUM_ITER):
    Project.m.find(validate=True).next()
    print '.',
    sys.stdout.flush()
elapsed = time.time() - begin
docs_per_s = float(NUM_ITER) / elapsed
ms_per_doc = 1000 / docs_per_s
github TurboGears / Ming / benchmarks / validation.py View on Github external
maintainers=Field([_person])
    developers=Field([_person])
    file_feed=Field(str)
    awards=Field([ dict(category=str, url=str, event=str, img_url=str) ])
    sf_piwik_siteid=Field(str)
    license=Field(S.Deprecated())
    license_uri=Field(str)
    license_title=Field(str)
    developer_page=Field(str)

    test_foo2=Field(S.Deprecated)
    fossforus_id=Field(S.Deprecated)
    fossforus_screenshots=Field(S.Deprecated)
    fossforus_features=Field(S.Deprecated)
    fossforus_tags=Field(S.Deprecated)
    fossforus_ratings=Field(S.Deprecated)
    _last_snapshot_id=Field(S.Deprecated)

print 'Begin test'
sys.stdout.flush()
begin = time.time()
for x in xrange(NUM_ITER):
    Project.m.find(validate=True).next()
    print '.',
    sys.stdout.flush()
elapsed = time.time() - begin
docs_per_s = float(NUM_ITER) / elapsed
ms_per_doc = 1000 / docs_per_s
print 'Validated %d docs in %d secs (%.2f docs/s, %d ms/doc)' % (
    NUM_ITER, elapsed, docs_per_s, ms_per_doc)
github rick446 / MongoPyChef / mongopychef / model / m_role.py View on Github external
from ming.orm import RelationProperty, ForeignIdProperty

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

log = logging.getLogger(__name__)

role = collection(
    'chef.role', doc_session,
    Field('_id', S.ObjectId()),
    Field('account_id', S.ObjectId(if_missing=None)),
    Field('name', str),
    Field('description', str),
    Field('default_attributes', str, if_missing='{}'),
    Field('override_attributes', str, if_missing='{}'),
    Field('run_list', [ str ] ),
    Field('env_run_lists', { str: [ str ]}),
    Index('account_id', 'name', unique=True))

class Role(ModelBase):

    @property
    def __name__(self):
        return self.name

    def __json__(self):
        d = dict(
            chef_type='role',
            json_class='Chef::Role',
            name=self.name,
            description=self.description,
            default_attributes=loads(self.default_attributes),
github apache / allura / Allura / allura / model / repository.py View on Github external
def add_meta_post(self, changes):
        tmpl = g.jinja2_env.get_template('allura:templates/repo/merge_request_changed.html')
        message = tmpl.render(changes=changes)
        self.discussion_thread.add_post(text=message, is_meta=True, ignore_security=True)



# 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
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(