Esempio n. 1
0
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
    def __name__(self):
        return str(self._id)

    def initialize(self, request):
        checksum_index = dict((self.file_id(cs), cs) for cs in self.checksums)
        existing_files = self.account.find_objects(ChefFile, dict(_id={"$in": checksum_index.keys()}))
        existing_files_by_id = dict((f._id, f) for f in existing_files)
        response = {}
Esempio n. 2
0
 def setUp(self):
     self.ds = datastore.DataStore('mim:///', database='test')
     self.Session = Session(bind=self.ds)
     self.TestFS = fs.filesystem(
         'test_fs', self.Session)
Esempio n. 3
0
 def setUp(self):
     self.ds = create_datastore('mim:///test')
     self.Session = Session(bind=self.ds)
     self.TestFS = fs.filesystem('test_fs', self.Session)
Esempio n. 4
0
 def setUp(self):
     self.ds = create_datastore("mim:///test")
     self.Session = Session(bind=self.ds)
     self.TestFS = fs.filesystem("test_fs", self.Session)
Esempio n. 5
0
    ming.Field('num_threads', int),
    ming.Field('num_posts', int),
    ming.Field('schema_version', ming.schema.Value(2, required=True)),
    version_of=M20.Forum,
    migrate=migrate_forum)

########NEW FILE########
__FILENAME__ = model
import ming
from ming import fs

from lesson_2_0 import model as M20

sess = M20.sess

Attachment = fs.filesystem(
    'forum.attachment', sess)

Attachment = fs.filesystem(
    'forum.attachment', sess,
    ming.Field('author', str))
    
Attachment = fs.filesystem(
    'forum.attachment', sess,
    ming.Field('metadata', dict(
            author=str)))
    

########NEW FILE########
__FILENAME__ = model
from ming.odm import ThreadLocalODMSession, Mapper
from ming.odm import ForeignIdProperty, RelationProperty
Esempio n. 6
0
 def setUp(self):
     self.ds = create_datastore('mim:///test')
     self.Session = Session(bind=self.ds)
     self.TestFS = fs.filesystem(
         'test_fs', self.Session)
Esempio n. 7
0
import ming
from ming import fs

from lesson_2_0 import model as M20

sess = M20.sess

Attachment = fs.filesystem("forum.attachment", sess)

Attachment = fs.filesystem("forum.attachment", sess, ming.Field("author", str))

Attachment = fs.filesystem("forum.attachment", sess, ming.Field("metadata", dict(author=str)))
Esempio n. 8
0
import ming
from ming import fs

from lesson_2_0 import model as M20

sess = M20.sess

Attachment = fs.filesystem('forum.attachment', sess)

Attachment = fs.filesystem('forum.attachment', sess, ming.Field('author', str))

Attachment = fs.filesystem('forum.attachment', sess,
                           ming.Field('metadata', dict(author=str)))