def forum_publish_save(context, REQUEST): scrub = scrubber.Scrubber().scrub response = {"status": "success"} content = REQUEST.form["content"] topic = _get_topic(context, REQUEST.form["topic"]) filename = REQUEST.form["filename"] if hasattr(topic, "forum_publish_objects"): content = scrub(content) site = context.getSite() doc = get_document_or_create(site, title=filename) doc_content = doc.getLocalAttribute("body", site.gl_get_selected_language()) doc_content += content # update Naaya document doc.set_localpropvalue("body", site.gl_get_selected_language(), doc_content) # doc.body = content doc.recatalogNyObject(doc) # clear preview document _clear_preview(context, REQUEST.form["topic"]) response["url"] = doc.absolute_url() REQUEST.RESPONSE.setHeader("Content-Type", "application/json") return simplejson.dumps(response) else: raise NotFound("No objects to publish")
from OFS.Folder import Folder from Globals import InitializeClass import Acquisition from AccessControl import ClassSecurityInfo from datetime import datetime from AccessControl.Permissions import view from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.ZCatalog.CatalogAwareness import CatalogAware import re import scrubber if 'any' not in dir(__builtins__): from Products.NaayaCore.backport import any scrubber.any = any sanitize = scrubber.Scrubber().scrub def trim(message): """ Remove leading and trailing empty paragraphs """ message = re.sub(r'^\s*<p>(\s*( )*)*\s*</p>\s*', '', message) message = re.sub(r'\s*<p>(\s*( )*)*\s*</p>\s*$', '', message) return message def cleanup_message(message): return sanitize(trim(message)).strip() from constants import * from utilities import *
print "connected" fL.send(s, "GETDELETEDATA|*") data = fL.recv(s) s.close() print "recvd to delete list" toDelete = [] for item in data.split("|"): if item != "": toDelete.append(item) # Create an instance of the Scrubber object, and initiate it. scrub = scrubber.Scrubber(toDelete) scrubStart = time.time() scrub.clean() scrubEnd = time.time() eTime = scrubEnd - scrubStart with open('scrub' + logName, 'a') as timeFile: timeFile.write(str(eTime) + '\n') # If the error list has any errors in it, send an email to the specified # addresses containing the errors if errorList != []: