예제 #1
0
    def createContent(self, name, content_type, obj_location, REQUEST,
                      **kwargs):
        """ """

        if isinstance(content_type, basestring):
            klass = self.get_model(content_type)
        else:
            klass = content_type

        if type(obj_location) == str:
            obj_location = find_model(self, obj_location)

        newobj = klass(name=name)
        newobj.put()
        # Hook content up to traveral machinery locations etc.. before
        # applying all the data
        if IContentish.providedBy(newobj):
            if obj_location:
                obj_location.addContent(newobj, name, REQUEST)
                zope.event.notify(zope.lifecycleevent.ObjectCreatedEvent(self))
                self.setcached(str(obj_location.getPath()), None)
        elif isinstance(newobj, NonContentishMixin):
            newobj.__parent__ = obj_location

        newobj.applyChanges(kwargs)
        newobj.put()

        return newobj
예제 #2
0
    def contentValues(self, REQUEST=None, kind=None):

        ct = []
        if kind and type(kind) == type(''):
            ct = [kind]
        elif kind:
            ct = kind

        if self.children_keys:
            results = [i for i in db.get(self.children_keys) if i != None]
            if ct:
                results = [i for i in results if i.kind() in ct]
            for i in results:
                try:
                    i.__parent__ = self
                except AttributeError:
                    logging.info('***could not set parent on %s' % repr(i))
            results.sort(
                lambda x, y: cmp(int(x.display_order), int(y.display_order)))

            return results
        else:
            return []
예제 #3
0
 def _iterate_props(self, obj):
     results = []
     for i in dir(obj):
         results.append((i, type(getattr(obj, i))))
     return results