Exemple #1
0
    def get(self, name, default=None):
        schema = storage.getSchema(IContentTypeSchema)

        item = schema.query(schema.Type.oid == name).first()
        if item is None:
            return default

        return IContentType(storage.getItem(item.oid))
Exemple #2
0
    def getUserByLogin(self, login):
        sch = storage.getSchema(IUserInfo)

        ds = sch.query(sch.Type.login == login).first()
        if ds is not None:
            user = storage.getItem(ds.oid)
            user.id = 'memphis-%s'%user.oid
            return user
Exemple #3
0
 def getUser(self, id):
     if id and id.startswith('memphis-'):
         try:
             user = storage.getItem(id[8:])
             user.id = id
             return user
         except:
             pass
Exemple #4
0
    def __item__(self):
        try:
            if self.__oid__ is None:
                self.__oid__ = self.__behavior__.getBehaviorOIDs().next()
            item = storage.getItem(self.__oid__)
        except StopIteration:
            item = storage.insertItem(self.__behavior__.name)
            self.__oid__ = item.oid

        return item
Exemple #5
0
    def get(cls, principal):
        if cls.__schema__ is None:
            cls.__schema__ = storage.getSchema(IPreferences)

        rec = cls.__schema__.query(
            cls.__schema__.Type.principal == principal).first()
        if rec is None:
            item = storage.insertItem(IPreferences)
            IPreferences(item).principal = principal
        else:
            item = storage.getItem(rec.oid)

        item.id = principal
        return Preferences(item)
Exemple #6
0
def getRoot():
    global rootOID

    behavior = storage.getBehavior(IRoot)
    try:
        if rootOID is None:
            rootOID = behavior.getBehaviorOIDs().next()
        return LocationProxy(storage.getItem(rootOID), None, "")
    except StopIteration:
        item = storage.insertItem(IRoot)
        rootOID = item.oid
        dc = IContent(item)
        dc.title = u"Site"
        dc.description = u"Default memphis site."

        event.notify(ObjectCreatedEvent(item))
        return LocationProxy(item, None, "")
Exemple #7
0
    def getPrincipal(self, passcode):
        sch = storage.getSchema(IPasswordReset)

        rec = sch.query(sch.Type.passcode == passcode).first()
        if rec is not None:
            return storage.getItem(rec.oid)
Exemple #8
0
def storageInitializedEvent(ev):
    sch = storage.getSchema(ISchema)
    
    for item in sch.query():
        ttwschema = ISchema(storage.getItem(item.oid))
        ttwschema.installSchema()
Exemple #9
0
def getContentType(item):
    try:
        return IContentType(storage.getItem(IContent(item).type), None)
    except KeyError:
        pass