コード例 #1
0
ファイル: models.py プロジェクト: brubeck/readify
                               LongField, ListField)

from brubeck.timekeeping import MillisecondField
from brubeck.datamosh import OwnedModelMixin, StreamedModelMixin

from brubeck.models import User, UserProfile

# We're going to use ObjectIds for the id fields
from dictshield.fields.mongo import ObjectIdField
from dictshield.document import diff_id_field

###
### Override the id fields to be ObjectIdFields
###

User = diff_id_field(ObjectIdField, ['id'], User)
UserProfile = diff_id_field(ObjectIdField, ['id', 'owner_id'], UserProfile)

###
### List Models
###


@diff_id_field(ObjectIdField, ['id', 'owner_id'])
class ListItem(Document, OwnedModelMixin, StreamedModelMixin):
    """Bare minimum to have the concept of streamed item.
    """
    # status fields
    liked = BooleanField(default=False)
    deleted = BooleanField(default=False)
    archived = BooleanField(default=False)
コード例 #2
0
ファイル: document.py プロジェクト: avsd/pyvotal
                elem = SubElement(root, name)
                elem.text = str(value)
                elem.attrib = attribs
        # allow sub classes to add custom ad-hoc fields
        self._contribute_to_xml(root)
        return tostring(root)

    def _contribute_to_xml(self, etree):
        pass

    def _contribute_from_etree(self, etree):
        pass

    xml_exclude = list()


class PyvotalDocument(Document, XMLMixin):
    """
    Base class for pivotal objects representation
    """

# py25 class decorator
PyvotalDocument = diff_id_field(IntField, ['id'])(PyvotalDocument)


class PyvotalEmbeddedDocument(EmbeddedDocument, XMLMixin):
    """
    Base class for embedded pivotal documents. i.e. tasks/notes
    """
    pass
コード例 #3
0
ファイル: models.py プロジェクト: brubeck/readify
from brubeck.timekeeping import MillisecondField
from brubeck.datamosh import OwnedModelMixin, StreamedModelMixin

from brubeck.models import User, UserProfile

# We're going to use ObjectIds for the id fields
from dictshield.fields.mongo import ObjectIdField
from dictshield.document import diff_id_field


###
### Override the id fields to be ObjectIdFields
###

User = diff_id_field(ObjectIdField, ['id'], User)
UserProfile = diff_id_field(ObjectIdField, ['id', 'owner_id'], UserProfile)


###
### List Models
###

@diff_id_field(ObjectIdField, ['id', 'owner_id'])
class ListItem(Document, OwnedModelMixin, StreamedModelMixin):
    """Bare minimum to have the concept of streamed item.
    """
    # status fields
    liked = BooleanField(default=False)
    deleted = BooleanField(default=False)
    archived = BooleanField(default=False)
コード例 #4
0
        # allow sub classes to add custom ad-hoc fields
        self._contribute_to_xml(root)
        return tostring(root)

    def _contribute_to_xml(self, etree):
        pass

    def _contribute_from_etree(self, etree):
        pass

    xml_exclude = list()


class PyvotalDocument(Document, XMLMixin):
    """
    Base class for pivotal objects representation
    """
    class Meta:
        id_field = IntField


# py25 class decorator
PyvotalDocument = diff_id_field(IntField, ['id'])(PyvotalDocument)


class PyvotalEmbeddedDocument(EmbeddedDocument, XMLMixin):
    """
    Base class for embedded pivotal documents. i.e. tasks/notes
    """
    pass