Beispiel #1
0
 def UpdateSort(self, objs, user):
     """    update pool_sort values according to list """
     if not objs:
         return False, _(u"List is empty")
     if isinstance(objs, basestring):
         objs = ConvertToNumberList(objs)
     ids = []
     for oi in objs:
         # check if listed objects are objects or ids
         if not IObject.providedBy(oi):
             ids.append(int(oi))
     objs2 = []
     if ids:
         # load remaining objects by id
         objs2 = self.GetObjsBatch(ids)
     pos = 10
     processed = []
     for obj in objs:
         if not IObject.providedBy(obj):
             for o in objs2:
                 if o.id == int(obj):
                     obj = o
                     break
         if not IObject.providedBy(obj):
             continue
         if obj.id in processed:
             continue
         processed.append(obj.id)
         obj.meta.set("pool_sort", pos)
         obj.CommitInternal(user)
         pos += 10
     return True, _(u"OK")
Beispiel #2
0
 def Paste(self, ids, pos, user):
     """
     Paste the copied object with id to this object
     """
     root = self.dataroot
     new = []
     msgs = []
     result = True
     for id in ids:
         id = int(id)
         if self.GetID() == id:
             continue
         obj = root.LookupObj(id, preload="skip")
         if not obj:
             msgs.append(_(u"Object not found"))
             result = False
             continue
         newobj = self.Duplicate(obj, user) 
         if not newobj:
             raise TypeError, "Duplicate failed"
         if ISort.providedBy(self):
             self.InsertAfter(newobj.id, pos, user=user)
         new.append(newobj)
     if not self.app.configuration.autocommit:
         for o in new:
             o.Commit(user)
     if result:
         msgs.append(_(u"OK. Copied and pasted."))
     return result, msgs
Beispiel #3
0
 def Paste(self, ids, pos, user):
     """
     Paste the copied object with id to this object
     """
     root = self.dataroot
     new = []
     msgs = []
     result = True
     for id in ids:
         id = int(id)
         if self.GetID() == id:
             continue
         obj = root.LookupObj(id, preload="skip")
         if not obj:
             msgs.append(_(u"Object not found"))
             result = False
             continue
         newobj = self.Duplicate(obj, user)
         if not newobj:
             raise TypeError, "Duplicate failed"
         if ISort.providedBy(self):
             self.InsertAfter(newobj.id, pos, user=user)
         new.append(newobj)
     if not self.app.configuration.autocommit:
         for o in new:
             o.Commit(user)
     if result:
         msgs.append(_(u"OK. Copied and pasted."))
     return result, msgs
Beispiel #4
0
 def UpdateSort(self, objs, user):
     """    update pool_sort values according to list """
     if not objs:
         return False, _(u"List is empty")
     if isinstance(objs, basestring):
         objs = ConvertToNumberList(objs)
     ids = []
     for oi in objs:
         # check if listed objects are objects or ids
         if not IObject.providedBy(oi):
             ids.append(int(oi))
     objs2 = []
     if ids:
         # load remaining objects by id
         objs2 = self.GetObjsBatch(ids)
     pos = 10
     processed = []
     for obj in objs:
         if not IObject.providedBy(obj):
             for o in objs2:
                 if o.id == int(obj):
                     obj = o
                     break
         if not IObject.providedBy(obj):
             continue
         if obj.id in processed:
             continue
         processed.append(obj.id)
         obj.meta.set("pool_sort", pos)
         obj.CommitInternal(user)
         pos += 10
     return True, _(u"OK")
Beispiel #5
0
 def delfile(self):
     self.ResetFlashMessages()
     file = self.GetFormValue(u"fid")
     try:
         r=self.context.DeleteFile(file, self.User())
         if not r:
             m=_(u"Delete failed")
         else:
             m=_(u"OK")
     except Exception, e:
         m=str(e)
Beispiel #6
0
 def delfile(self):
     self.ResetFlashMessages()
     file = self.GetFormValue(u"fid")
     try:
         r = self.context.DeleteFile(file, self.User())
         if not r:
             m = _(u"Delete failed")
         else:
             m = _(u"OK")
     except Exception, e:
         m = str(e)
Beispiel #7
0
    def pageListWidget(self,
                       page=None,
                       pages=None,
                       showCCP=False,
                       defaultview=u""):
        """
        Widget with existing pages list and edit options
        call with page = current page
        """
        if not page:
            page = self.context
        html = u"""<div class="subpages"> %(blocks)s </div>"""

        pHtml = u"""<div class="element">
  <div class="el_title">%(workflow)s <a href="%(url)s" title="%(aTitle)s">%(title)s </a> </div>
  <div class="el_options">%(options)s</div>
  <br style="clear:both">
</div>"""

        useworkflow = 1
        localizer = translator(self.request)
        static = self.StaticUrl("nive_cms.workflow:static/exclamation.png")

        if not pages:
            pages = page.GetPages(includeMenu=1)
        blocks = StringIO()
        for p in pages:
            wf = u""
            if useworkflow and not p.meta.pool_state:
                wf = u"""<a href="%(url)s@workflow" class="right" rel="niveOverlay"><img src="%(static)s" title="%(name)s"></a>""" % {
                    u"static": static,
                    u"url": self.FolderUrl(p),
                    u"name": localizer(_(u"This page is not public."))
                }
            title = p.meta.get(u"title")
            linkTitle = u"ID: %d, %s" % (p.id, title)
            options = self.editBlockList(obj=p,
                                         page=page,
                                         showCCP=showCCP,
                                         showWF=False)
            blocks.write(
                pHtml % {
                    u"url": self.FolderUrl(p) + defaultview,
                    u"aTitle": linkTitle,
                    u"title": title,
                    u"options": options,
                    u"workflow": wf
                })
        if not len(pages):
            blocks.write(u"""<div class="element">""")
            blocks.write(localizer(_(u"<p><i>no sub pages</i></p>")))
            blocks.write(u"""</div>""")
        return html % {u"blocks": blocks.getvalue()}
Beispiel #8
0
    def Move(self, ids, pos, user):
        """
        Move the object with id to this object
        
        Events
        
        - beforeAdd(data=obj.meta, type=type)
        - afterDelete(id=obj.id)
        - moved()
        - afterAdd(obj=obj)
        """
        root = self.dataroot
        oldParent=None

        moved = []
        msgs = []
        result = True
        for id in ids:
            id = int(id)
            if self.GetID() == id:
                continue
            obj = root.LookupObj(id, preload="skip")
            if not obj:
                msgs.append(_(u"Object not found"))
                result = False
                continue

            type=obj.GetTypeID()
            # allow subobject
            if not self.IsTypeAllowed(type, user):
                raise TypeError, "Object cannot be added here"

            self.Signal("beforeAdd", data=obj.meta, type=type)
            if not oldParent or oldParent.id != obj.parent.id:
                oldParent = obj.parent
            obj.__parent__ = self
            obj.meta["pool_unitref"] = self.GetID()
            oldParent.Signal("afterDelete", id=obj.id)
            obj.Signal("moved")
            #obj.Close()
            moved.append(obj)

        for o in moved:
            o.Commit(user)
            if ISort.providedBy(self):
                self.InsertAfter(o.id, pos, user=user)
            self.Signal("afterAdd", obj=o)
        if result:
            msgs.append(_(u"OK. Cut and pasted."))
        return result, msgs
Beispiel #9
0
    def Move(self, ids, pos, user):
        """
        Move the object with id to this object
        
        Events
        
        - beforeAdd(data=obj.meta, type=type)
        - afterDelete(id=obj.id)
        - moved()
        - afterAdd(obj=obj)
        """
        root = self.dataroot
        oldParent = None

        moved = []
        msgs = []
        result = True
        for id in ids:
            id = int(id)
            if self.GetID() == id:
                continue
            obj = root.LookupObj(id, preload="skip")
            if not obj:
                msgs.append(_(u"Object not found"))
                result = False
                continue

            type = obj.GetTypeID()
            # allow subobject
            if not self.IsTypeAllowed(type, user):
                raise TypeError, "Object cannot be added here"

            self.Signal("beforeAdd", data=obj.meta, type=type)
            if not oldParent or oldParent.id != obj.parent.id:
                oldParent = obj.parent
            obj.__parent__ = self
            obj.meta["pool_unitref"] = self.GetID()
            oldParent.Signal("afterDelete", id=obj.id)
            obj.Signal("moved")
            #obj.Close()
            moved.append(obj)

        for o in moved:
            o.Commit(user)
            if ISort.providedBy(self):
                self.InsertAfter(o.id, pos, user=user)
            self.Signal("afterAdd", obj=o)
        if result:
            msgs.append(_(u"OK. Cut and pasted."))
        return result, msgs
Beispiel #10
0
    def delete(self):
        self.ResetFlashMessages()
        class DeleteForm(HTMLForm):
            def Delete(self, action, **kw):
                redirectSuccess = kw.get("redirectSuccess")
                msgs = []
                result,data,errors = self.Validate(self.request)
                if result:
                    obj=self.context
                    user = kw.get("user") or self.view.User()
                    obj = self.context.obj(data.get("id"))
                    if not obj:
                        result = False
                        msgs = [_(u"Object not found")]
                    else:
                        result = self.context.Delete(id, user=user, obj=obj)
                return self._FinishFormProcessing(result, data, msgs, errors, **kw)

        form = DeleteForm(view=self)
        form.actions = [
            Conf(id="default",    method="StartRequestGET", name=u"Initialize",     hidden=True),
            Conf(id="delete",     method="Delete",    name=_(u"Delete all"),  hidden=False),
        ]
        form.fields = [
            FieldConf(id="id",     name=u"ids",   datatype="number", hidden=True, required=True),
        ]
        form.use_ajax = True
        form.Setup()
        result, data, action = form.Process(redirectSuccess="page_url")
        obj = self.context.obj(self.GetFormValue(u"id"))
        return {u"content": data, u"result": result, u"cmsview":self, u"objToDelete": obj, u"head": form.HTMLHead()}
Beispiel #11
0
 def sortelements(self):
     """
     display the sortview and editor
     """
     self.ResetFlashMessages()
     result = {
         u"msgs": [],
         u"content": u"",
         u"cmsview": self,
         u"result": False,
         u"sortelements": []
     }
     ids = self.GetFormValue(u"ids")
     sort = self.GetFormValue(u"sort")
     if sort != u"1":
         result[u"sortelements"] = self.context.GetSortElements("elements")
         return result
     ids = ConvertToNumberList(ids)
     if not ids:
         result[u"sortelements"] = self.context.GetSortElements("elements")
         result[u"msgs"] = [_(u"Nothing to sort.")]
         return result
     user = self.User()
     ok, msgs = self.context.UpdateSort(ids, user=user)
     result[u"msgs"] = [msgs]
     result[u"result"] = ok
     result[u"sortelements"] = self.context.GetSortElements("elements")
     return result
Beispiel #12
0
 def _Convert(self, profile):
     source = self.files.get(profile.source)
     if not source or not source.tempfile:
         # convert only if tempfile
         return False, ()
     if not source:
         return False, [_(u"Image not found: ") + profile.source]
     p = DvPath()
     p.SetUniqueTempFileName()
     p.SetExtension(profile.extension)
     destPath = str(p)
     
     try:
         try:
             source.file.seek(0)
         except:
             pass
         try:
             iObj = Image.open(source)
         except IOError:
             # no file to be converted
             return False, ()
         iObj = iObj.convert("RGB")
         
         # resize
         size = [profile.width, profile.height]
         if size[0] != 0 or size[1] != 0:
             if size[0] == 0:    
                 size[0] = size[1]
             elif size[1] == 0:    
                 size[1] = size[0]
             x, y = iObj.size
             if x > size[0]: y = y * size[0] / x; x = size[0]
             if y > size[1]: x = x * size[1] / y; y = size[1]
             size = x, y
         
         iObj = iObj.resize(size, Image.ANTIALIAS)
         iObj.save(destPath, profile.format)
         try:
             source.file.seek(0)
         except:
             pass
         
         # file meta data
         imgFile = open(destPath)
         filename = DvPath(profile.dest+"_"+source.filename)
         filename.SetExtension(profile.extension)
         file = File(filekey=profile.dest, 
                     filename=str(filename), 
                     file=imgFile,
                     size=p.GetSize(), 
                     path=destPath, 
                     extension=profile.extension,  
                     tempfile=True)
         self.files.set(profile.dest, file)
     finally:
         # clean temp file
         p.Delete()
     return True, []
Beispiel #13
0
 def design(self):
     fields = (FieldConf(
         id=u"columns",
         datatype="lines",
         size=100,
         required=0,
         name=_(u"Column names"),
         description=
         _(u"Column names used in the main template. For multiple columns enter one per line."
           )), )
     form = ConfigurationForm(view=self,
                              context=self.context.configuration,
                              app=self.context)
     form.fields = fields
     form.Setup()
     # process and render the form.
     result, data, action = form.Process()
     return {u"content": data, u"result": result, u"head": form.HTMLHead()}
Beispiel #14
0
 def design(self):
     fields = (
         FieldConf(id=u"columns", datatype="lines",  size=100,  required=0, name=_(u"Column names"), description=_(u"Column names used in the main template. For multiple columns enter one per line.")),
     )
     form = ConfigurationForm(view=self, context=self.context.configuration, app=self.context)
     form.fields = fields
     form.Setup() 
     # process and render the form.
     result, data, action = form.Process()
     return {u"content": data, u"result": result, u"head": form.HTMLHead()}
Beispiel #15
0
 def selectPageElement(self):
     user = self.User()
     lt = self.context.GetAllowedTypes(user)
     tmpl = u"""<a href="@add?pool_type=%s" rel="niveOverlay" class="nivecms addlink">%s</a> """
     html = StringIO()
     html.write(u"""<div class="addElements">""")
     #opt
     for t in lt:
         html.write(tmpl % (t[u"id"], _(t[u"name"])))
     html.write(u"</div>")
     return html.getvalue()
Beispiel #16
0
 def selectPageElement(self):
     user = self.User()
     lt = self.context.GetAllowedTypes(user)
     tmpl = u"""<a href="@add?pool_type=%s" rel="niveOverlay" class="nivecms addlink">%s</a> """
     html = StringIO()
     html.write(u"""<div class="addElements">""")
     #opt
     for t in lt:
         html.write(tmpl % (t[u"id"], _(t[u"name"])))
     html.write(u"</div>")
     return html.getvalue()
Beispiel #17
0
 def action(self):
     transition = self.GetFormValue(u"t")
     url = self.GetFormValue("redirect_url")
     if not url:
         url = self.PageUrl()
         
     user = self.User()
     self.context.WfAction("", user, transition=transition)
     self.context.CommitInternal(user)
     msg = _(u"OK")
     self.Redirect(url, messages=[msg])
Beispiel #18
0
 def Delete(self, action, **kw):
     msgs = []
     result,data,errors = self.Validate(self.request)
     if result:
         user = kw.get("user") or self.view.User()
         obj = self.context.obj(data.get("id"))
         if not obj:
             result = False
             msgs = [_(u"Object not found")]
         else:
             result = self.context.Delete(id, user=user, obj=obj)
     return self._FinishFormProcessing(result, data, msgs, errors, **kw)
Beispiel #19
0
 def copy(self):
     """
     """
     self.ResetFlashMessages()
     ids = self.GetFormValue(u"ids")
     if not ids:
         ids = [self.context.id]
     cp = self.SetCopyInfo(u"copy", ids, self.context)
     url = self.GetFormValue(u"url")
     if not url:
         url = self.PageUrl(self.context)
     msgs = _(u"OK. Copied.")
     return self.Redirect(url, [msgs], refresh=True)
Beispiel #20
0
 def copy(self):
     """
     """
     self.ResetFlashMessages()
     ids = self.GetFormValue(u"ids")
     if not ids:
         ids = [self.context.id]
     cp = self.SetCopyInfo(u"copy", ids, self.context)
     url = self.GetFormValue(u"url")
     if not url:
         url = self.PageUrl(self.context)
     msgs = _(u"OK. Copied.")
     return self.Redirect(url, [msgs], refresh=True)
Beispiel #21
0
    def pageListWidget(self, page=None, pages=None, showCCP=False, defaultview=u""):
        """
        Widget with existing pages list and edit options
        call with page = current page
        """
        if not page:
            page=self.context
        html = u"""<div class="subpages"> %(blocks)s </div>"""
        
        pHtml = u"""<div class="element">
  <div class="el_title">%(workflow)s <a href="%(url)s" title="%(aTitle)s">%(title)s </a> </div>
  <div class="el_options">%(options)s</div>
  <br style="clear:both">
</div>"""
        
        useworkflow = 1
        localizer = translator(self.request)
        static = self.StaticUrl("nive_cms.workflow:static/exclamation.png")

        if not pages:
            pages = page.GetPages(includeMenu=1)
        blocks = StringIO()
        for p in pages:
            wf = u""
            if useworkflow and not p.meta.pool_state:
                wf = u"""<a href="%(url)s@workflow" class="right" rel="niveOverlay"><img src="%(static)s" title="%(name)s"></a>""" % {
                                    u"static": static,
                                    u"url": self.FolderUrl(p),
                                    u"name": localizer(_(u"This page is not public."))
                                }
            title = p.meta.get(u"title")
            linkTitle = u"ID: %d, %s" % (p.id, title)
            options = self.editBlockList(obj=p, page=page, showCCP=showCCP, showWF=False)
            blocks.write(pHtml % {u"url": self.FolderUrl(p)+defaultview, u"aTitle": linkTitle, u"title": title, u"options": options, u"workflow": wf})
        if not len(pages):
            blocks.write(u"""<div class="element">""")
            blocks.write(localizer(_(u"<p><i>no sub pages</i></p>")))
            blocks.write(u"""</div>""")
        return html % {u"blocks": blocks.getvalue()}
Beispiel #22
0
    def delete(self):
        self.ResetFlashMessages()

        class DeleteForm(HTMLForm):
            def Delete(self, action, **kw):
                redirectSuccess = kw.get("redirectSuccess")
                msgs = []
                result, data, errors = self.Validate(self.request)
                if result:
                    obj = self.context
                    user = kw.get("user") or self.view.User()
                    obj = self.context.obj(data.get("id"))
                    if not obj:
                        result = False
                        msgs = [_(u"Object not found")]
                    else:
                        result = self.context.Delete(id, user=user, obj=obj)
                return self._FinishFormProcessing(result, data, msgs, errors,
                                                  **kw)

        form = DeleteForm(view=self)
        form.actions = [
            Conf(id="default",
                 method="StartRequestGET",
                 name=u"Initialize",
                 hidden=True),
            Conf(id="delete",
                 method="Delete",
                 name=_(u"Delete all"),
                 hidden=False),
        ]
        form.fields = [
            FieldConf(id="id",
                      name=u"ids",
                      datatype="number",
                      hidden=True,
                      required=True),
        ]
        form.use_ajax = True
        form.Setup()
        result, data, action = form.Process(redirectSuccess="page_url")
        obj = self.context.obj(self.GetFormValue(u"id"))
        return {
            u"content": data,
            u"result": result,
            u"cmsview": self,
            u"objToDelete": obj,
            u"head": form.HTMLHead()
        }
Beispiel #23
0
 def Delete(self, action, **kw):
     redirectSuccess = kw.get("redirectSuccess")
     msgs = []
     result, data, errors = self.Validate(self.request)
     if result:
         obj = self.context
         user = kw.get("user") or self.view.User()
         obj = self.context.obj(data.get("id"))
         if not obj:
             result = False
             msgs = [_(u"Object not found")]
         else:
             result = self.context.Delete(id, user=user, obj=obj)
     return self._FinishFormProcessing(result, data, msgs, errors,
                                       **kw)
Beispiel #24
0
    def Process(self, images=None, profiles=None):
        """
        Process images and create versions from profiles. ::
        
            images = list of image field ids to process. if none all images based on 
                     selected profiles are processed.
            profiles = list of profiles to process. if none all profiles are 
                       processed
            returns result, messages
        
        Example: If `Process(images=['highres'],profiles=None)` all versions with
        `source=highres` are updated.

        Events: 
        updateImage(profile)

        """
        if not PILloaded:
            return False, [_(u"Python image library (PIL) not installed.")]
        convert = []
        if not images:
            for p in self.configuration.imageProfiles:
                if not self._CheckCondition(p):
                    continue
                convert.append(p)
        else:
            for p in self.configuration.imageProfiles:
                if not self._CheckCondition(p):
                    continue
                if p.source in images:
                    convert.append(p)
        if not convert:
            return True
        msgs = []
        result = True
        for profile in convert:
            r, m = self._Convert(profile)
            msgs += m
            if not r:
                result = False
            else:
                self.Signal("updateImage", profile=profile)
        return result, msgs
Beispiel #25
0
 def movebottom(self):
     """
     move pageelement to bottom in container
     redirect to request.url
     parameter: id, url in request
     """
     self.ResetFlashMessages()
     try:
         id = int(self.GetFormValue(u"id"))
     except:
         id = 0
     if not id:
         ok = False
         msgs = _(u"Not found")
     else:
         ok, msgs = self.context.MoveEnd(id, user=self.User())#, selection="elements")
     url = self.GetFormValue(u"url")
     if not url:
         url = self.PageUrl(self.context)
     return self.Redirect(url, [msgs], refresh=ok)
Beispiel #26
0
 def movebottom(self):
     """
     move pageelement to bottom in container
     redirect to request.url
     parameter: id, url in request
     """
     self.ResetFlashMessages()
     try:
         id = int(self.GetFormValue(u"id"))
     except:
         id = 0
     if not id:
         ok = False
         msgs = _(u"Not found")
     else:
         ok, msgs = self.context.MoveEnd(
             id, user=self.User())  #, selection="elements")
     url = self.GetFormValue(u"url")
     if not url:
         url = self.PageUrl(self.context)
     return self.Redirect(url, [msgs], refresh=ok)
Beispiel #27
0
 def sortelements(self):
     """
     display the sortview and editor
     """
     self.ResetFlashMessages()
     result = {u"msgs": [], u"content":u"", u"cmsview": self, u"result": False, u"sortelements":[]}
     ids = self.GetFormValue(u"ids")
     sort = self.GetFormValue(u"sort")
     if sort != u"1":
         result[u"sortelements"] = self.context.GetSortElements("elements")
         return result
     ids = ConvertToNumberList(ids)
     if not ids:
         result[u"sortelements"] = self.context.GetSortElements("elements")
         result[u"msgs"] = [_(u"Nothing to sort.")]
         return result
     user = self.User()
     ok, msgs = self.context.UpdateSort(ids, user=user)
     result[u"msgs"] = [msgs]
     result[u"result"] = ok
     result[u"sortelements"] = self.context.GetSortElements("elements")
     return result
Beispiel #28
0
    def paste(self):
        """
        """
        self.ResetFlashMessages()
        deleteClipboard=1
        url = self.GetFormValue(u"url")
        if not url:
            url = self.PageUrl(self.context)
        action, ids = self.GetCopyInfo()
        if not action or not ids:
            msgs = []
            return self.Redirect(url, msgs, refresh=True)

        pepos = self.GetFormValue(u"pepos",0)
        result = False
        msgs = [_(u"Method unknown")]
        if action == u"cut":
            result, msgs = self.context.Move(ids, pepos, user=self.User())
            if result and deleteClipboard:
                cp = self.DeleteCopyInfo()
        elif action == u"copy":
            result, msgs = self.context.Paste(ids, pepos, user=self.User())
        return self.Redirect(url, msgs, refresh=result)
Beispiel #29
0
    def paste(self):
        """
        """
        self.ResetFlashMessages()
        deleteClipboard = 1
        url = self.GetFormValue(u"url")
        if not url:
            url = self.PageUrl(self.context)
        action, ids = self.GetCopyInfo()
        if not action or not ids:
            msgs = []
            return self.Redirect(url, msgs, refresh=True)

        pepos = self.GetFormValue(u"pepos", 0)
        result = False
        msgs = [_(u"Method unknown")]
        if action == u"cut":
            result, msgs = self.context.Move(ids, pepos, user=self.User())
            if result and deleteClipboard:
                cp = self.DeleteCopyInfo()
        elif action == u"copy":
            result, msgs = self.context.Paste(ids, pepos, user=self.User())
        return self.Redirect(url, msgs, refresh=result)
Beispiel #30
0
    def GetElementContainer(self):
        # return the current element container
        return self #.parent
    
    def GetContainer(self):
        # return the current element container
        return self.parent




#@nive_module
configuration =  ObjectConf(
    id = "box",
    name = _(u"Box"),
    dbparam = "box",
    context = "nive_cms.box.box",
    template = "box.pt",
    selectTag = StagPageElement,
    subtypes = ("nive.definitions.INonContainer",),
    container = True,
    icon = "nive_cms.cmsview:static/images/types/box.png",
    description = _(u"A box is a container to group elements on a page. It can be used as an" 
                    u"advanced styling element for web pages. The box itself only stores a title and styling selector.")
)

# data definition ------------------------------------------------------------------

configuration.data = [
    FieldConf(id="span", datatype="list", size=20, default=u"", listItems=(), 
Beispiel #31
0
    def Init(self):
        self.ListenEvent("commit", "TextToTitle")


    def TextToTitle(self, **kw):
        text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True)
        self.meta["title"] = CutText(text, self.titleLen, postfix=u"")
        return True


# text type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "text",
    name = _(u"Text"),
    dbparam = "texts",
    context = "nive_cms.text.text",
    template = "text.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/text.png",
    description = _(u"Text element for the web page. Can be used to add headers, preformatted text and paragraphs to the web page. ")
)

configuration.data = [
    FieldConf(id="textblock", datatype="htext", size=100000, default=u"", name=_(u"Text"), fulltext=True, description=u""),
]

fields = ["textblock", "pool_groups"]
configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}}
Beispiel #32
0
    implements(ICMSRoot)
    extension = u"html"
    
    def Init(self):
        self.__acl__ = (
            (Allow, 'group:editor', 'view'),
            (Allow, 'group:author', 'view'),
            (Allow, 'group:reviewer', 'view'),
            (Allow, 'group:reader', 'view'),
            (Allow, 'group:admin', 'view'),
            (Deny, Everyone, 'view'),
        )




# Root definition ------------------------------------------------------------------
#@nive_module
configuration = RootConf(
    id = "editor",
    context = "nive_cms.cmsview.cmsroot.cmsroot",
    template = "root.pt",
    default = False,
    subtypes = "*",
    name = _(u"Home"),
    extensions = ("nive.extensions.persistentRoot.Persistent",),
    description = __doc__
)

configuration.views = []
Beispiel #33
0
            (Allow, 'group:reviewer', 'view'),
            (Allow, 'group:reader', 'view'),
            (Allow, 'group:admin', 'view'),
            (Deny, Everyone, 'view'),
        )


# Root definition ------------------------------------------------------------------
#@nive_module
configuration = RootConf(
    id="editor",
    context="nive_cms.cmsview.cmsroot.cmsroot",
    template="root.pt",
    default=False,
    subtypes="*",
    name=_(u"Home"),
    extensions=("nive.extensions.persistentRoot.Persistent", ),
    description=__doc__)

configuration.data = [
    FieldConf(id=u"pool_filename",
              datatype="string",
              size=30,
              required=1,
              name=_(u"Root url name"),
              settings={"validator": RootnameValidator},
              default=u""),
    FieldConf(id=u"title",
              datatype="string",
              size=255,
              required=0,
Beispiel #34
0
    def Init(self):
        self.ListenEvent("commit", "TextToTitle")

    def TextToTitle(self, **kw):
        text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True)
        self.meta["title"] = CutText(text, self.titleLen, postfix=u"")
        return True
    


# note type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "note",
    name = _(u"Note"),
    dbparam = "notes",
    context = "nive_cms.note.note",
    template = "note.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/note.png",
    description = _(u"Simple text note for authors. The note is only visible to cms authors and not published.")
)

configuration.data = [
    FieldConf(id="textblock", datatype="htext", size=50000, default=u"", name=_(u"Note"), description=u"")
]

fields = ["textblock", "pool_groups"]
configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}}
Beispiel #35
0
from nive_cms.i18n import _
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementBase


class spacer(PageElementBase):
    pass
    


# type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "spacer",
    name = _(u"Spacer"),
    dbparam = "spacers",
    context = "nive_cms.spacer.spacer",
    template = "spacer.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/spacer.png",
    description = _(u"Styling element to add line breaks and vertical space between elements.")
)

configuration.data = [
    FieldConf(id="cssClass", datatype="list", size=5, default=u"", listItems=(), name=_(u"Styling"), description=u"")
]

fields =["cssClass", "pool_groups"]
configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}}
Beispiel #36
0
Administration interface extensions
"""

from pyramid.renderers import render

from nive_cms.i18n import _
from nive.definitions import ViewConf, ViewModuleConf, FieldConf, WidgetConf, Conf
from nive.definitions import IApplication, IAdminWidgetConf
from nive.adminview.view import AdminBasics, ConfigurationForm

# view module definition ------------------------------------------------------------------

#@nive_module
configuration = ViewModuleConf("nive.adminview.view",
                               id="cms_admin",
                               name=_(u"CMS Administration"),
                               context=IApplication,
                               view="nive_cms.cmsview.admin.CMSAdminView",
                               templates="nive.adminview:",
                               permission="administration")

t = configuration.templates
configuration.views = [
    ViewConf(name="design", attr="design", renderer=t + "form.pt"),
    ViewConf(name="help",
             attr="help",
             renderer=t + "help.pt",
             permission="read"),
]

configuration.widgets = [
Beispiel #37
0
    
     
    def Init(self):
        self.ListenEvent("commit", "FilenameToTitle")

    def FilenameToTitle(self, **kw):
        if self.files.get("file") and not self.meta["title"]:
            self.meta["title"] = self.files.get("file")["filename"]
        


# file type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "file",
    name = _(u"File"),
    dbparam = "files",
    context = "nive_cms.file.file",
    template = "file.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/file.png",
    description = _(u"The file element provides a simple file download with title and optional description.")
)

configuration.data = [
    FieldConf(id="file",       datatype="file",  size=0,     default=u"", fulltext=1, name=_(u"File"), description=u""),
    FieldConf(id="textblock",  datatype="htext", size=10000, default=u"", name=_(u"Description"), fulltext=1, description=u"")
]

fields = ["title", "file", "textblock", "pool_groups"]
configuration.forms = {"create": {"fields":fields}, "edit": {"fields":fields}}
Beispiel #38
0
"""

from nive_cms.i18n import _
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementBase


class news(PageElementBase):
    pass


# news type definition ------------------------------------------------------------------
# @nive_module
configuration = ObjectConf(
    id="news",
    name=_(u"News"),
    dbparam="news",
    context="nive_cms.news.news",
    template="news.pt",
    selectTag=StagPageElement,
    icon="nive_cms.cmsview:static/images/types/news.png",
    description=_(u"Simple news item with title, text, image, publish date and link."),
)

configuration.data = [
    FieldConf(id="image", datatype="file", size=0, default=u"", name=_(u"Imagefile"), description=u""),
    FieldConf(id="textblock", datatype="htext", size=100000, default=u"", fulltext=1, name=_(u"Text"), description=u""),
    FieldConf(
        id="publish",
        datatype="date",
        size=0,
Beispiel #39
0
    titleLen = 20

    def Init(self):
        self.ListenEvent("commit", "TextToTitle")

    def TextToTitle(self, **kw):
        text = ConvertHTMLToText(self.data.get("textblock"), removeReST=True)
        self.meta["title"] = CutText(text, self.titleLen, postfix=u"")
        return True


# text type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id="text",
    name=_(u"Text"),
    dbparam="texts",
    context="nive_cms.text.text",
    template="text.pt",
    selectTag=StagPageElement,
    icon="nive_cms.cmsview:static/images/types/text.png",
    description=
    _(u"Text element for the web page. Can be used to add headers, preformatted text and paragraphs to the web page. "
      ))

configuration.data = [
    FieldConf(id="textblock",
              datatype="htext",
              size=100000,
              default=u"",
              name=_(u"Text"),
Beispiel #40
0
    def IsLinked(self):
        """
        returns True if the page is redirected in public mode. 
        """
        return self.data["pagelink"]

    def IsPage(self):
        return True
    

# type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "page",
    name = _(u"Page"),
    dbparam = "pages",
    context = "nive_cms.page.page",
    template = "page.pt",
    selectTag = StagPage,
    container = True,
    workflowEnabled = True,
    icon = "nive_cms.cmsview:static/images/types/page.png",
    description = _(u"Pages are rendered as html files and make up the website.")
)

configuration.data = [
    FieldConf(id="header", datatype="string", size=255, default=u"", fulltext=1, 
              name=_(u"Page header"), description=_(u"Text shown at top of the page")),
    FieldConf(id="titleImage", datatype="file", size=0, default=u"", 
              name=_(u"Title image"), description=""),
Beispiel #41
0
class cmsroot(PageRootBase):

    #implements(IWebsiteRoot, ICMSRoot)
    implements(ICMSRoot)
    extension = u"html"

    def Init(self):
        self.__acl__ = (
            (Allow, 'group:editor', 'view'),
            (Allow, 'group:author', 'view'),
            (Allow, 'group:reviewer', 'view'),
            (Allow, 'group:reader', 'view'),
            (Allow, 'group:admin', 'view'),
            (Deny, Everyone, 'view'),
        )


# Root definition ------------------------------------------------------------------
#@nive_module
configuration = RootConf(
    id="editor",
    context="nive_cms.cmsview.cmsroot.cmsroot",
    template="root.pt",
    default=False,
    subtypes="*",
    name=_(u"Home"),
    extensions=("nive.extensions.persistentRoot.Persistent", ),
    description=__doc__)

configuration.views = []
Beispiel #42
0
        return self

    def GetContainer(self):
        return self.parent

    def GetColumn(self, name):
        if name == self.meta["title"]:
            return self
        return self.GetPage().GetColumn(name)


# type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id="column",
    name=_(u"Column"),
    dbparam="columnbox",
    context="nive_cms.column.column",
    template="column.pt",
    hidden=True,
    selectTag=StagPageElement,
    container=True,
    icon="nive_cms.cmsview:static/images/types/column.png",
    description=
    _(u"A column is a container to group elements on a page. Columns are not added like"
      u"normal page elements but have to be defined manually in the main template. A column can"
      u"be inherited through a hierarchy of pages."))
configuration.data = [
    FieldConf(
        id="showsub",
        datatype="bool",
Beispiel #43
0
"""
Contains the grid system css classes to be used in edit forms.
The lists are mapped to the elements' form definitions on startup.

Most of the class names defined here are default bootstrap 3.
"""

from nive.definitions import Conf
from nive_cms.i18n import _


grid_span = (
    {'id': u'col-md-1', 'name': _(u'Span 1')},
    {'id': u'col-md-2', 'name': _(u'Span 2')},
    {'id': u'col-md-3', 'name': _(u'Span 3')},
    {'id': u'col-md-4', 'name': _(u'Span 4')},
    {'id': u'col-md-5', 'name': _(u'Span 5')},
    {'id': u'col-md-6', 'name': _(u'Span 6')},
    {'id': u'col-md-7', 'name': _(u'Span 7')},
    {'id': u'col-md-8', 'name': _(u'Span 8')},
    {'id': u'col-md-9', 'name': _(u'Span 9')},
    {'id': u'col-md-10', 'name': _(u'Span 10')},
    {'id': u'col-md-11', 'name': _(u'Span 11')},
    {'id': u'col-md-12', 'name': _(u'Span 12 (100% width)')},
    {'id': u'jumbotron', 'name': _(u'Top box')}
)

grid_offset = (
    {'id': u'', 'name': _(u'none')},
    {'id': u'col-md-offset-1', 'name': _(u'Offset 1')},
Beispiel #44
0
from nive.security import ALL_PERMISSIONS, Allow, Everyone, Deny
from nive.components.objects.base import ApplicationBase
from nive_cms.extensions.path import AlternateAppPath

#@nive_module
configuration = AppConf(
    id = "website",
    title = u"Nive cms",
    context = "nive_cms.app.WebsitePublisher",
    workflowEnabled = True,
    columns=[u"footer"],
    translations="nive_cms:locale/"
)

configuration.meta.append(FieldConf(id="pool_groups", datatype="checkbox", size=250, default="",
                                    name=_(u"Permission"), 
                                    description=_(u"Only displayed to users in the selected group")))

configuration.modules = [
    # objects
    "nive_cms.box", "nive_cms.column", "nive_cms.menublock", "nive_cms.file", 
    "nive_cms.image", "nive_cms.media", "nive_cms.note", "nive_cms.text",
    "nive_cms.news", "nive_cms.spacer", "nive_cms.link", "nive_cms.codeblock",
    # page, root
    "nive_cms.root", "nive_cms.page", 
    # cms editor
    "nive_cms.cmsview",
    # design: not included by default
    #"nive_cms_design_bs3"
    # workflow
    "nive_cms.workflow",
Beispiel #45
0
from nive.definitions import IPage
from nive.workflow import WfProcessConf, WfStateConf, WfTransitionConf
from nive_cms.i18n import _


# change pool_state to publish or revoke
def publish(transition, context, user, values):
    context.meta.set("pool_state", 1)
    
def revoke(transition, context, user, values):
    context.meta.set("pool_state", 0)


wfProcess = WfProcessConf(
    id = "default",
    name = _(u"Simple Publishing Workflow"),
    apply = (IPage,),
    states = (
        WfStateConf(
            id = "start",
            name = _(u"New object"),
            actions = ("delete","duplicate","edit","add","remove")
        ),
        WfStateConf(
            id = "edit",
            name = _(u"Edit"),
            actions = ("delete","duplicate","edit","add","remove")
        ),
        WfStateConf(
            id = "public",
            name = _(u"Public"),
Beispiel #46
0
    extension = u"html"

    def Init(self):
        self.queryRestraints = {"pool_state": 1}, {}


# Root definition ------------------------------------------------------------------
#@nive_module
configuration = RootConf(
    id="content",
    context="nive_cms.root.root",
    template="root.pt",
    default=True,
    subtypes="*",
    extensions=("nive.extensions.persistentRoot.Persistent", ),
    name=_(u"Home"),
    description=
    _(u"The root is the home page of the website. All contained pages and elements are stored in the database."
      ))

# Disabled "nive_cms.extensions.path.PersistentRootPath"

configuration.data = [
    FieldConf(id=u"description",
              datatype="text",
              size=5000,
              required=0,
              name=_(u"Root description")),
]

fields = [
Beispiel #47
0
from nive_cms.i18n import _
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementBase


class code(PageElementBase):
    """
    """


# text type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id="code",
    name=_(u"Code"),
    dbparam="codes",
    context="nive_cms.codeblock.code",
    template="code.pt",
    selectTag=StagPageElement,
    icon="nive_cms.cmsview:static/images/types/code.png",
    description=
    _(u"Text element to add code snippets to web pages. Supports Javascript, HTML and CSS."
      ))

ct = [
    {
        'id': u'raw',
        'name': _(u'No format')
    },
    {
Beispiel #48
0
"""

from nive_cms.i18n import _
from nive.definitions import StagPageElement, ObjectConf, FieldConf
from nive_cms.baseobjects import PageElementBase


class news(PageElementBase):
    pass


# news type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "news",
    name = _(u"News"),
    dbparam = "news",
    context = "nive_cms.news.news",
    template = "news.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/news.png",
    description = _(u"Simple news item with title, text, image, publish date and link.")
)

configuration.data = [
    FieldConf(id="image",     datatype="file",  size=0,      default=u"", name=_(u"Imagefile"), description=u""),
    FieldConf(id="textblock", datatype="htext", size=100000, default=u"", fulltext=1, name=_(u"Text"), description=u""),
    FieldConf(id="publish",   datatype="date",  size=0,      default=u"", required=0, name=_(u"Date"), description=_(u"Used as publish date on the website.")),
    FieldConf(id="cssClass",  datatype="list",  size=10,     default=u"", listItems=(), name=_(u"Styling"), description=u""),
    FieldConf(id="link",      datatype="url",   size=1000,   default=u"", name=_(u"Link"), description=u"")
]
Beispiel #49
0
    # container
    ViewConf(name="@add",       attr="add",    context = IContainer, renderer = t+"add.pt", permission="add"),
    ViewConf(name="@delete",    attr="delete", context = IContainer, renderer = t+"delete.pt", permission = "delete"),
    
    # widgets
    ViewConf(name="@addpageWidget",  attr="tmpl", renderer = t+"widgets/widget_addpage.pt",    context = IContainer, permission="add"),
    ViewConf(name="@editpageWidget", attr="tmpl", renderer = t+"widgets/widget_editpage.pt",   context = IContainer, permission="edit"),
    ViewConf(name="@editrootWidget", attr="tmpl", renderer = t+"widgets/widget_editroot.pt",   context = IContainer, permission="edit"),
    ViewConf(name="@subpagesWidget", attr="tmpl", renderer = t+"widgets/widget_subpages.pt",   context = IContainer),
    ViewConf(name="@settingsWidget", attr="tmpl", renderer = t+"widgets/widget_settings.pt",   context = IContainer)
] + sort.views + cutcopy.views


# toolbox and editor widgets ----------------------------------------------------------------------------------
configuration.widgets = [
    WidgetConf(name=_(u"Add new page"),         widgetType=IToolboxWidgetConf, apply=(IContainer,), viewmapper="@addpageWidget",  id="cms.addpage", sort=100),
    WidgetConf(name=_(u"Edit page"),            widgetType=IToolboxWidgetConf, apply=(IPage,),      viewmapper="@editpageWidget", id="cms.editpage", sort=200),
    WidgetConf(name=_(u"Edit root"),            widgetType=IToolboxWidgetConf, apply=(IRoot,),      viewmapper="@editrootWidget", id="cms.editroot", sort=200),
    WidgetConf(name=_(u"Sub pages and parent"), widgetType=IToolboxWidgetConf, apply=(IContainer,), viewmapper="@subpagesWidget", id="cms.subpages", sort=300),
    WidgetConf(name=_(u"Settings"),             widgetType=IToolboxWidgetConf, apply=(IApplication,IContainer), viewmapper="@settingsWidget", id="cms.settings", sort=400),
    
    WidgetConf(name=_(u"Contents"),      widgetType=IEditorWidgetConf, apply=(IContainer,),  viewmapper="@view",      id="editor.view", sort=0),
    WidgetConf(name=_(u"Add"),           widgetType=IEditorWidgetConf, apply=(IContainer,),  viewmapper="@add",       id="editor.add",  sort=100),
    WidgetConf(name=_(u"Edit"),          widgetType=IEditorWidgetConf, apply=(IObject,IRoot),viewmapper="@edit",      id="editor.edit", sort=200),
    WidgetConf(name=_(u"Sort sub pages"),widgetType=IEditorWidgetConf, apply=(IPage,IRoot),  viewmapper="@sortpages", id="editor.sortpages", sort=300),
    WidgetConf(name=_(u"Sort elements"), widgetType=IEditorWidgetConf, apply=(IPageElementContainer,), viewmapper="@sortelements", id="editor.sortelements", sort=300),
    WidgetConf(name=_(u"Meta"),          widgetType=IEditorWidgetConf, apply=(IObject,IRoot),viewmapper="@meta",      id="editor.meta", sort=900)
]


        
Beispiel #50
0
    # bw 0.9.11
    def Span(self):
        # css class span for the css selection
        if self.data.cssClass == "teaserl":
            return u"span4"
        elif self.data.cssClass == "teasers":
            return u"span2"
        return u"span3"


# image type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id="image",
    name=_(u"Image"),
    dbparam="images",
    context="nive_cms.image.image",
    template="image.pt",
    selectTag=StagPageElement,
    extensions=[],
    icon="nive_cms.cmsview:static/images/types/image.png",
    description=_(u"The image element inserts images into the web page."))

configuration.data = [
    FieldConf(id="image",
              datatype="file",
              size=0,
              default=u"",
              name=_(u"Imagefile")),
    FieldConf(id="imagefull",
Beispiel #51
0
        if menu == u"sub":
            return self.GetPage().GetPages(hidden=0, **kw)
        elif menu == u"level":
            p = self.GetPage().parent
            if not p:
                #root
                p = self.GetPage()
            return p.GetPages(hidden=0, **kw)
        return []


# text type definition ------------------------------------------------------------------
#@nive_module
configuration = ObjectConf(
    id = "menublock",
    name = _(u"Navigation"),
    dbparam = "menublocks",
    context = "nive_cms.menublock.menublock",
    template = "menublock.pt",
    selectTag = StagPageElement,
    icon = "nive_cms.cmsview:static/images/types/menublock.png",
    description = _(u"Element to render navigation trees and linked table of contents. The menublock can be used as main navigation for the web page.")
)

menu=[  {'id': u'sub', 'name': _(u'Sub pages')},
        {'id': u'level', 'name': _(u'Same level pages')},
        {'id': u'tree', 'name': _(u'Tree navigation')},
        {'id': u'subtree', 'name': _(u'Tree navigation - first level as base')},
]
configuration.data = [
    FieldConf(id="menutype", datatype="list", size=12, default=u"", name=_(u"Menu type"), listItems=menu, description=u"")
Beispiel #52
0
    def elementListWidget(self, obj=None, elements=None, addResponse=True, showCCP=True, defaultview=u"@edit"):
        """
        Widget with existing elements list and edit options
        call with obj = current object / page
        """
        #i18n?
        if not obj:
            obj=self.context
        html = u"""<div>
  <h4 onclick="$.fn.editblocks().toggleBlock('#elements%(id)s',event)">%(title)s</h4>
  %(blocks)s
</div>
        """
        
        elHtml = u"""<div class="element">
  <div class="el_title"><a href="%(link)s" class="nivecms" rel="niveOverlay">%(title)s</a></div>
  <div class="el_options">%(options)s</div>
  <br style="clear:both">
</div>"""
        
        if not elements:
            elements = obj.GetPageElements()
            
        localizer = translator(self.request)
        
        blocks = StringIO()
        static = self.StaticUrl("nive_cms.cmsview:static/images/types/")
        for el in elements:
        
            t = el.GetTitle()
            if not t:
                t = u"<em>%s</em>" % (localizer(el.GetTypeName(), self.request))

            if el.configuration.get('icon'):
                src = self.StaticUrl(el.configuration.get('icon')) 
            else: 
                src = '%s%s.png' % (static, el.GetTypeID())
            
            if el.IsContainer():
                title = u"<img src='%s' align='top'> %s: %s" % (src, localizer(el.GetTypeName()), t)
                blocks.write(elHtml % {u"title": title, u"link": self.FolderUrl(el)+defaultview, u"options": self.editBlockList(obj=el, showCCP=showCCP)})
                for elb in el.GetPageElements():
                    if elb.configuration.get('icon'):
                        srcb = self.StaticUrl(elb.configuration.get('icon')) 
                    else: 
                        srcb = '%s%s.png' % (static, elb.GetTypeID())
                    t = elb.GetTitle()
                    if not t:
                        t = u"<em>%s</em>" % (localizer(elb.GetTypeName()))
                    title = u"&gt; <img src='%s' align='top'> %s" % (srcb, t)
                    blocks.write(elHtml % {u"title": title, u"link": self.FolderUrl(elb)+defaultview, u"options": self.editBlockList(obj=elb, showCCP=showCCP)})
        
            else:
                title = u"<img src='%s' align='top'> %s" % (src, t)
                blocks.write(elHtml % {u"title": title, u"link": self.FolderUrl(el)+defaultview, u"options": self.editBlockList(obj=el, showCCP=showCCP)})
        if not len(elements):
            blocks.write(localizer(_(u"<p><i>empty</i></p>")))
        data = html % {u"blocks": blocks.getvalue(), u"id": str(obj.GetID()), u"title": localizer(_(u"Page elements"))}
        if addResponse:
            r = Response(content_type="text/html", conditional_response=True)
            r.unicode_body = data
            return r
        return data