How to use the persistence.dict.PersistentDict function in Persistence

To help you get started, we’ve selected a few Persistence 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 owenmorris / chandler / chandler / application / model_deprecated / ContactEntityItem.py View on Github external
from LocalRepository import LocalRepository

from ContactMethodItem import ContactMethodItem
from ContactName import ContactName
from ContactAttributes import ContactAttributes
from ContactFormat import ContactFormat

from RdfRestriction import RdfRestriction

from RdfNamespace import dc
from RdfNamespace import chandler

class ContactEntityItem(InformationItem):
    """EntityItem"""

    rdfs = PersistentDict()
    
    rdfs[chandler.contactType] = RdfRestriction(str, 1)
    rdfs[chandler.name] = RdfRestriction(ContactName, 1)
    rdfs[chandler.contactMethods] = RdfRestriction(ContactMethodItem, 0)
    rdfs[chandler.photoURL] = RdfRestriction(str, 1)
    rdfs[chandler.attributes] = RdfRestriction(ContactAttributes, 1)
    rdfs[chandler.format] = RdfRestriction(ContactFormat, 1)
    rdfs[chandler.groups] = RdfRestriction(str, 0)


    def __init__(self, contactType):
        InformationItem.__init__(self)

        self.contactType = contactType
 
        self.name = ContactName(self)
github owenmorris / chandler / chandler / application / model_deprecated / EventItem.py View on Github external
from ReminderItem import ReminderItem
from FreeBusy import FreeBusy
from PlaceItem import PlaceItem
from CalendarItem import CalendarItem

from mx.DateTime import *

_DateTimeType = type(now())
_DateTimeDurationType = type(now() - now())

class EventItem(InformationItem):

    # Define the schema for EventItem
    # -----------------------------------

    rdfs = PersistentDict()
    
    rdfs[chandler.startTime] = RdfRestriction(_DateTimeType, 1)
    rdfs[chandler.endTime] = RdfRestriction(_DateTimeType, 1)
    rdfs[chandler.headline] = RdfRestriction(str, 1)
    rdfs[chandler.recurrence] = RdfRestriction(RecurrencePattern) 
    rdfs[chandler.reminder] = RdfRestriction(InformationItem) 
    rdfs[chandler.timeTransparency] = RdfRestriction(FreeBusy)
    rdfs[chandler.participant] = RdfRestriction(EntityItem)
    rdfs[chandler.invitee] = RdfRestriction(EntityItem)
    rdfs[chandler.location] = RdfRestriction(PlaceItem) 
    rdfs[chandler.calendar] = RdfRestriction(CalendarItem)
    
    def __init__(self):
        InformationItem.__init__(self)

    def getStartTime(self):
github owenmorris / chandler / chandler / application / model_deprecated / GroupItem.py View on Github external
from persistence.dict import PersistentDict

from RdfObject import RdfObject
from RdfRestriction import RdfRestriction
from RdfNamespace import chandler

from EntityItem import EntityItem

class GroupItem(GroupItem):
    """GroupItem"""

    # Define the schema for GroupItem
    # ----------------------------------

    rdfs = PersistentDict()

    rdfs[chandler.members] = RdfRestriction(EntityItem)

    def __init__(self):
        RdfObject.__init__(self)

    def getMembers(self):
        return self.getRdfAttribute(chandler.members,
                                    GroupItem.rdfs)

    def setMembers(self, members):
        return self.setRdfAttribute(chandler.members,
                                    members,
                                    GroupItem.rdfs)

    members = property(getMembers, setMembers)
github owenmorris / chandler / chandler / application / model_deprecated / FreeBusy.py View on Github external
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"

from persistence.dict import PersistentDict

from RdfObject import RdfObject
from RdfRestriction import RdfRestriction

from RdfNamespace import chandler

class FreeBusy(RdfObject):
    """FreeBusy"""

    # Define the schema for FreeBusy
    # ----------------------------------

    rdfs = PersistentDict()

    def __init__(self):
        RdfObject.__init__(self)
github owenmorris / chandler / chandler / application / model_deprecated / ContactMethodItem.py View on Github external
from persistence.dict import PersistentDict

from InformationItem import InformationItem

from RdfRestriction import RdfRestriction

from RdfNamespace import dc
from RdfNamespace import chandler

import ContactMethodAttributes

class ContactMethodItem(InformationItem):
    """ContactMethodItem"""

    rdfs = PersistentDict()
    
    rdfs[chandler.methodType] = RdfRestriction(str, 1)
    rdfs[chandler.methodDescription] = RdfRestriction(str, 1)
    rdfs[chandler.methodAddress] = RdfRestriction(ContactMethodAttributes.ContactMethodAttributes, 1)
    rdfs[chandler.methodComment] = RdfRestriction(str, 1)
   
    def __init__(self, methodType, methodDescription, attributes):
        InformationItem.__init__(self)
        
        self.SetMethodType(methodType)
        self.SetMethodDescription(methodDescription)
        self.InitMethodAddress(attributes)

    # methods to get and set all of the fields
    def GetMethodType(self):
        return self.getRdfAttribute(chandler.methodType, ContactMethodItem.rdfs)
github owenmorris / chandler / chandler / parcels / osaf / repository / RepositoryView.py View on Github external
def AddAttributes(self, attrId, item):
        for key in item.keys():
            element = item[key]
            if isinstance(element, Thing):
                newId = self.treeCtrl.AddNewItem(attrId, key, [element.GetURL()])
                # @@@ FIXME: Note: cycles are possible!
                self.AddAttributes(newId, element)
            elif isinstance(element, types.ListType) or isinstance(element, PersistentList):
                self.AddListItem(element, attrId, key)
            elif isinstance(element, types.TupleType):
                self.AddTupleType(element, attrId, key)
            elif isinstance(element, types.DictType) or isinstance(element, PersistentDict):
                self.AddDictItem(element, attrId, key)
            else:
                self.treeCtrl.AddNewItem(attrId, key, [str(element)])
github owenmorris / chandler / chandler / application / model_deprecated / Address.py View on Github external
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"

from persistence.dict import PersistentDict

from RdfObject import RdfObject
from RdfRestriction import RdfRestriction

from RdfNamespace import chandler

class Address(RdfObject):
    """Address"""

    # Define the schema for Addresses
    # ---------------------------------------

    rdfs = PersistentDict()
    rdfs[chandler.address1] = RdfRestriction(str, 1)
    rdfs[chandler.address2] = RdfRestriction(str, 1)
    rdfs[chandler.address3] = RdfRestriction(str, 1)
    rdfs[chandler.city] = RdfRestriction(str, 1)
    rdfs[chandler.state] = RdfRestriction(str, 1)
    rdfs[chandler.zip] = RdfRestriction(str, 1)
    rdfs[chandler.country] = RdfRestriction(str, 1)

    def __init__(self):
        RdfObject.__init__(self)
github owenmorris / chandler / chandler / application / model_deprecated / ContactName.py View on Github external
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"

from persistence.dict import PersistentDict

from RdfObject import RdfObject
from RdfRestriction import RdfRestriction

from RdfNamespace import chandler

class ContactName(RdfObject):
    """ContactNAme"""

# many of these strings should really be enumerated types; we'll convert them
# to that when the infrastructure is ready.

    rdfs = PersistentDict()

    rdfs[chandler.fullname] = RdfRestriction(str, 1)
    rdfs[chandler.sortname] = RdfRestriction(str, 1)
    rdfs[chandler.firstname] = RdfRestriction(int, 1)
    rdfs[chandler.middlename] = RdfRestriction(str, 1)
    rdfs[chandler.lastname] = RdfRestriction(str, 1)
    rdfs[chandler.nickname] = RdfRestriction(str, 1)
    rdfs[chandler.honorific] = RdfRestriction(str, 1)
    rdfs[chandler.suffix] = RdfRestriction(str, 1)
    
    def __init__(self, contactItem):
        RdfObject.__init__(self)

        self.contactItem = contactItem
 
    def GetNamePart(self, partName):
github owenmorris / chandler / chandler / application / model_deprecated / CalendarItem.py View on Github external
from persistence.dict import PersistentDict

from RdfObject import RdfObject
from RdfRestriction import RdfRestriction
from RdfNamespace import chandler

from InformationItem import InformationItem

class CalendarItem(InformationItem):
    """CalendarItem"""

    # Define the schema for CalendarItem
    # ----------------------------------

    rdfs = PersistentDict()

    rdfs[chandler.name] = RdfRestriction(str, 1)

    def __init__(self):
        RdfObject.__init__(self)

    def getName(self):
        return self.getRdfAttribute(chandler.name, CalendarItem.rdfs)

    def setName(self, name):
        self.setRdfAttribute(chandler.name, name, CalendarItem.rdfs)

    name = property(getName, setName)
github owenmorris / chandler / chandler / application / model_deprecated / InformationItem.py View on Github external
class InformationItem(RdfObject, Observable):
    """Information Item"""

    # The url for the InformationItem class: might want to do this
    # differently
    url = chandler.InformationItem

    # Define the schema for InformationItem
    # -------------------------------------------------------------
    # Note: recursive references to InformationItem (via EntityItem as
    # well) prevent using InformationItem and EntityItem types -- need
    # to fix this somehow. Perhaps we'll need to use strings instead of
    # types.

    rdfs = PersistentDict()
    
    rdfs[dc.identifier] = RdfRestriction(str, 1)
    rdfs[dc.subject] = RdfRestriction(str, 1) # dcq.SubjectSchema
    rdfs[dc.relation] = RdfRestriction(InformationItem)
    rdfs[chandler.linkedWith] = RdfRestriction(InformationItem)
    rdfs[chandler.annotatedBy] = RdfRestriction(InformationItem)
    rdfs[dc.title] = RdfRestriction(str, 1)
    rdfs[dc.creator] = RdfRestriction(EntityItem)
    rdfs[dc.date] = RdfRestriction(_DateTimeType) 
    rdfs[chandler.dateCreated] = RdfRestriction(_DateTimeType, 1)
    rdfs[chandler.dateModified] = RdfRestriction(_DateTimeType, 1)
    rdfs[dc.description] = RdfRestriction(str, 1)
    rdfs[chandler.project] = RdfRestriction(RdfObject) #ProjectItem 
    rdfs[dc.contributor] = RdfRestriction(EntityItem)
    rdfs[dc.type] = RdfRestriction(str) # some enumeration?
    rdfs[dc.source] = RdfRestriction(str)