def initialize(context):
    """
    Add the BoaDebugger to the Zope root 
    """
    #
    # need this for icon registration :)
    #
    context.registerClass(
        BoaDebugger.BoaDebugger,
        permission=view_management_screens,
        visibility=None,
        constructors=(BoaDebugger.manage_addBoaDebugger, ),
        icon='www/boa.gif',
    )
    context.registerHelp()

    app = context._ProductContext__app
    if not hasattr(app, 'BoaDebugger'):
        try:
            BoaDebugger.manage_addBoaDebugger(app)
            get_transaction().note('Added BoaDebugger')
            get_transaction().commit()
            zLOG.LOG('BoaDebugger', zLOG.INFO, 'Created new BoaDebugger')
        except:
            zLOG.LOG('BoaDebugger', zLOG.ERROR,
                     'Failed to create new BoaDebugger!')
            raise
    def setMemberProperties(self, mapping):
        """Overridden to store a copy of certain user data fields in an SQL database"""
        # Only pass relevant fields to the database
        db_args = dict([(f, v) for (f, v) in mapping.items()
                        if f in DB_FIELDS and self.getProperty(f) != v])
        dbtool = getToolByName(self, 'portal_moduledb')
        if dbtool and db_args:
            # We have to pass in aq_parent to be our own parent,
            # otheriwse the ZSQL method will acquire blank arguments
            # from the property sheet
            if not self.member_catalog(getUserName=self.getId()):
                zLOG.LOG(
                    "MemberData", zLOG.INFO,
                    "INSERT memberdata for %s: %s" % (self.getId(), db_args))
                dbtool.sqlInsertMember(aq_parent=self.aq_parent,
                                       id=self.getId(),
                                       **db_args)
            else:
                zLOG.LOG(
                    "MemberData", zLOG.INFO,
                    "UPDATE memberdata for %s: %s" % (self.getId(), db_args))
                dbtool.sqlUpdateMember(aq_parent=self.aq_parent,
                                       id=self.getId(),
                                       **db_args)

        BaseMemberData.setMemberProperties(self, mapping)
    def writeToGood(self, binData, strUser, strOriginalFileName):
        bSaveToTemp = True
        bHarvestingOn = (len(self.config['harvest_dir_success']) > 0)
        # zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "bHarvestingOn is %s" % bHarvestingOn)
        (strHead, strTail) = os.path.split(strOriginalFileName)
        (strRoot, strExt) = os.path.splitext(strTail)

        if bHarvestingOn:
            strHarvestDirectory = self.config['harvest_dir_success']
            # zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "Harvested directory: " + strHarvestDirectory)
            (strHarvestDirectory,
             strFileName) = harvestImportFile(binData, strHarvestDirectory,
                                              strOriginalFileName, strUser)
            if len(strFileName) > 0:
                bSaveToTemp = False
                strFileName = strHarvestDirectory + strFileName
                zLOG.LOG("LaTeX2CNXML Transform", zLOG.INFO,
                         "Harvested imported LaTeX doc: " + strFileName)
            else:
                zLOG.LOG(
                    "LaTeX2CNXML Transform", zLOG.INFO,
                    "Failed to harvest imported LaTeX doc " +
                    strOriginalFileName + " to directory " +
                    strHarvestDirectory)

        if bSaveToTemp:
            strFileName = tempfile.mktemp(suffix=strExt)
            # zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "No harvested directory.  Writing to temporary file instead: %s" % strFileName)
            file = open(strFileName, 'w')
            file.write(binData)
            file.close()

        return strFileName
 def moveToBad(self,strFileName):
     bHarvestingOn = ( len(self.config['harvest_dir_failure']) > 0 )
     if bHarvestingOn:
         strBadHarvestDirectory = self.config['harvest_dir_failure']
         zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "Moving: %s" % strFileName)
         zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "to: %s" % strBadHarvestDirectory)
         strNewFileName = moveImportFile(strFileName,strBadHarvestDirectory)
         if len(strNewFileName) == 0:
             zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "Failed to move BAD imported Word doc: %s" % strFileName)
Exemple #5
0
    def test_error(self):
        try:
            1 / 0
        except ZeroDivisionError:
            err = sys.exc_info()

        zLOG.LOG("basic", zLOG.INFO, "summary")
        zLOG.LOG("basic", zLOG.ERROR, "raised exception", error=err)
        with self.getLogFile() as f:
            self.verifyEntry(f, subsys="basic", summary="summary")
            self.verifyEntry(f, subsys="basic", severity=zLOG.ERROR, error=err)
    def convert(self, data, outdata, **kwargs):
        ### JCC TODO: all the back and forth about whether the data is a
        ###           file or data should be streamlined, if possible

        strOriginalFileName = kwargs['original_file_name']
        strUserName = kwargs['user_name']
        zLOG.LOG("OOo2CNXML Transform", zLOG.INFO,
                 "Original file name is : \"" + strOriginalFileName + "\". User is : \"" + strUserName + "\"")

        # write the file to disk; attempt to harvest to central location else put in /tmp
        strFileName = self.writeToGood(data,strUserName,strOriginalFileName)
        if strOriginalFileName.endswith('.xml'):
            zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "Input file is a .xml file.  Terminate import.")
            # importing .xml file sometime blows up the OOo server and lacks a use case so we punt.
            self.moveToBad(strFileName)
            raise OOoImportError, "Could not convert .xml file.  Please try another file type."

        # OOo convert a doc file into an XML file embedded in a zip file.
        try:
            binOOoData = self.convertWordToOOo(strFileName)
        except:
            self.moveToBad(strFileName)
            raise

        if len(binOOoData) == 0:
            zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "Open Office does not return anything.  The Open Office server may not be running.")
            # don't know for sure if the conversion failed, so do we leave
            # the harvested word file in the GOOD directory or do we leave
            # the word file in the BAD directory?  Choosing to keep the GOOD
            # as pristine as possible at the current time.
            self.moveToBad(strFileName)
            raise OOoImportError, "Could not convert file"

        fileOOo = StringIO(binOOoData)
        try:
            elCnxml, filesDict, errors = odt2cnxml.transform(fileOOo)
            from lxml import etree
            strCnxml = etree.tostring(elCnxml, pretty_print=True)
        except OOoImportError:
            # toCnxml() wrote log messages
            self.moveToBad(strFileName)
            raise OOoImportError, "Generated CNXML is invalid"

        fileCnxmlClean = StringIO(strCnxml)
        outdata.setData(fileCnxmlClean)

        # Add images
        objects = filesDict #{}
        outdata.setSubObjects(objects)

        self.cleanup(strFileName)

        return outdata
Exemple #7
0
    def generate_id(self, portal_type, batch_size=None):
        """ Generate a new id for 'portal_type'
        """
        plone = getSite()
        portal_id = plone.getId()

        if portal_type == 'News Item':
            portal_type = 'NewsItem'

        idserver_url = os.environ.get('IDServerURL')
        try:
            if batch_size:
                # GET
                f = urllib.urlopen(
                    '%s/%s%s?%s' %
                    (idserver_url, portal_id, portal_type,
                     urllib.urlencode({'batch_size': batch_size})))
            else:
                f = urllib.urlopen('%s/%s%s' %
                                   (idserver_url, portal_id, portal_type))
            id = f.read()
            f.close()
        except:
            from sys import exc_info
            info = exc_info()
            import zLOG
            zLOG.LOG(
                'INFO', 0, '',
                'generate_id raised exception: %s, %s \n idserver_url: %s' %
                (info[0], info[1], idserver_url))
            raise IDServerUnavailable(_('ID Server unavailable'))
        return id
Exemple #8
0
def query_reverse_geocode(lat, lon):
    """ calls reverse_geocode and logs the error """
    try:
        return reverse_geocode(lat, lon)
    except GeocoderServiceError, e:
        zLOG.LOG('naaya.observatory', zLOG.PROBLEM, str(e))
        return '', ''
def idserver_generate_id(context, prefix, batch_size=None):
    """ Generate a new id using external ID server.
    """
    plone = context.portal_url.getPortalObject()
    url = api.get_bika_setup().getIDServerURL()

    try:
        if batch_size:
            # GET
            f = urllib.urlopen('%s/%s/%s?%s' %
                               (url, plone.getId(), prefix,
                                urllib.urlencode({'batch_size': batch_size})))
        else:
            f = urllib.urlopen('%s/%s/%s' % (url, plone.getId(), prefix))
        new_id = f.read()
        f.close()
    except:
        from sys import exc_info
        info = exc_info()
        zLOG.LOG(
            'INFO', 0, '',
            'generate_id raised exception: %s, %s \n ID server URL: %s' %
            (info[0], info[1], url))
        raise IDServerUnavailable(_('ID Server unavailable'))

    return new_id
    def _queryBrain(self, uid, searchMethodName, default=None):
        """This helper method does the "hard work" of querying the catalog
           and interpreting the results.
        """
        if uid is None:
            return default

        # convert the uid to the right format
        generator = getToolByName(self, 'portal_uidgenerator')
        uid = generator.convert(uid)

        catalog = getToolByName(self, 'portal_catalog')
        searchMethod = getattr(catalog, searchMethodName)
        result = searchMethod({self.UID_ATTRIBUTE_NAME: uid})
        len_result = len(result)

        # return None if no object found with this uid
        if len_result == 0:
            return default

        # print a message to the log  if more than one object has
        # the same uid (uups!)
        if len_result > 1:
            zLOG.LOG("CMUid ASSERT:", zLOG.INFO,
                     "Uups, %s objects have '%s' as uid!!!" % \
                     (len_result, uid))

        return result[0]
Exemple #11
0
 def read_user(self):
     # XXX This could be cleaned up a bit.
     line = self.rfile.readline()
     if line == "":
         return False
     parts = line.split()
     if parts[0] != "USER":
         self.wfile.write("-ERR Invalid command; must specify USER first\n")
         return False
     user = parts[1]
     i = user.rfind("@")
     username = user[:i]
     server = user[i+1:]
     i = server.find(":")
     if i == -1:
         server = server, 110
     else:
         port = int(server[i+1:])
         server = server[:i], port
     zLOG.LOG("POP3", zLOG.INFO, "Got connect for %s" % repr(server))
     self.connect_pop(server)
     self.pop_wfile.write("USER %s\r\n" % username)
     resp = self.pop_rfile.readline()
     # As long the server responds OK, just swallow this reponse.
     if resp.startswith("+OK"):
         return True
     else:
         return False
Exemple #12
0
    def handle_pop_response(self, req):
        # Return True if connection is still open
        cmd, args = self.parse_request(req)
        multiline = self.is_multiline(cmd, args)
        firstline = self.pop_rfile.readline()
        zLOG.LOG("POP3", zLOG.DEBUG, "command %s multiline %s resp %s"
                 % (cmd, multiline, firstline.strip()))
        if multiline:
            # Collect the entire response as one string
            resp = StringIO.StringIO()
            while 1:
                line = self.pop_rfile.readline()
                resp.write(line)
                # The response is finished if we get . or an error.
                # XXX should handle byte-stuffed response
                if line == ".\r\n":
                    break
                if line.startswith("-ERR"):
                    break
            buf = resp.getvalue()
        else:
            buf = None

        handler = getattr(self, "handle_%s" % cmd, None)
        if handler:
            firstline, buf = handler(cmd, args, firstline, buf)

        self.wfile.write(firstline)
        if buf is not None:
            self.wfile.write(buf)
        if cmd == "QUIT":
            return False
        else:
            return True
    def notify(self, lenses, object, template, **kwargs):
        """
        Render the mail template provided using the object as context and email it to the adress associated with the lens.
        """

        host = self.MailHost
        for lens in lenses:
            #           try:
            # we cannot pass 'lens' as it might be private and thus unauthorized to the current user
            lensTitle = lens.Title()
            lensURL = lens.absolute_url()
            included = not lens[object.objectId].getVersionStop()
            lensCreator = lens.Creator()

            if lens.notifyOfChanges:
                mail_text = template(self,
                                     lensTitle=lensTitle,
                                     lensURL=lensURL,
                                     included=included,
                                     lensCreator=lensCreator,
                                     object=object,
                                     **kwargs)
                try:
                    host.send(mail_text)
                except ConflictError:
                    raise
                except Exception, e:
                    import zLOG
                    zLOG.LOG("Lensmaker", zLOG.ERROR,
                             "Error sending mail: " + str(e))
Exemple #14
0
    def searchForMembers(self, REQUEST=None, **kw):
        """Search for users (not groups, not groups-as-users) of a site """
        if REQUEST:
            dict = REQUEST
        else:
            dict = kw

        name = dict.get('name', '')
        # Split up search terms but leave quoted ones together
        try:
            names = shlex.split(name)
        except ValueError:
            try:
                names = shlex.split(name.replace("'", "\\'"))
            except ValueError:
                names = shlex.split(name.replace("'", "\\'") + '"')

        # Short circuit: if all that was asked for was '*', just return everyone
        if names == ['*']:
            query = And()
        else:
            queries = []
            for name in names:
                queries.extend([
                    MatchGlob('fullname', name),
                    MatchGlob('email', name),
                    Eq('getUserName', name)
                ])
            query = Or(*queries)
        zLOG.LOG('MembershipTool', zLOG.BLATHER, 'Querying: %s' % query)

        catalog = getToolByName(self, 'member_catalog')
        return catalog.evalAdvancedQuery(query, ('surname', 'firstname'))
    def translate(self, error):
        """Translate the given error.

            error: ErrorTranslationHint
            returns: ErrorTranslationHint instance

            This means the hint will be set to a value useful for the user.

            The actual work is done by the rules. We only try to find the
            actual rule that matches this error. Then the rule has to do the
            work.
        """
        assert IErrorTranslator.IErrorTranslationHint.isImplementedBy(error), \
                "ErrorTranslator interface not satisfied"


        rules = self.discoverRules()

        is_translated = 0
        for rule in rules:
            if (IErrorTranslator.IErrorTranslationRule.isImplementedBy(rule)
                    and rule.isResponsible(error)):
                rule.translate(error)
                is_translated = 1
                break

        if not is_translated and not error.field:
            zLOG.LOG('ErrorTranslator', zLOG.INFO, 'Untranslated exception occured', str(error))
            error.field = ERROR_FIELD_BLANK
            error.description = error.hint

        return error
def LCRetrieveSite(self, skiplist=[]):
    """Retrieves the links from all objects in the site."""
    lc = self.portal_linkchecker
    server = lc.database._getWebServiceConnection()
    if server is None:
        raise RuntimeError, "The site could not be crawled because no " \
                            "connection to the lms could be established."
    server.setClientNotifications(False)

    #    # Not actually necessary on every crawl, but it doesn't seem to work
    #    # in the installer, so this seems the next logical place to do it.
    #    self.portal_catalog.reindexIndex('portal_linkchecker_uid', self.REQUEST)
    try:
        database = lc.database
        # gather all objects that are of a type we can check for links
        for type in lc.retrieving.listSupportedTypes():
            if type in skiplist:
                zLOG.LOG("CMFLinkChecker", zLOG.INFO,
                         "Skipping, because %s is in skiplist" % type)
                continue
            objects = self.portal_catalog(portal_type=type, Language='all')
            os_ = len(objects)
            i = 0
            for ob in objects:
                i += 1
                zLOG.LOG("CMFLinkChecker", zLOG.BLATHER, "Site Crawl Status",
                         "%s of %s (%s)" % (i, os_, ob.getPath()))
                ob = ob.getObject()
                if ob is None:
                    # Maybe the catalog isn't up to date
                    continue
                #try:
                lc.retrieving.retrieveObject(ob)
                #except Exception,e:
                #    zLOG.LOG('CMFLinkChecker', zLOG.INFO,
                #      "Unable to retrieveObject for %s. Error: %s" %([ob], e))
                if i % 500 == 0:
                    transaction.commit()
                    zLOG.LOG(
                        'CMFLinkChecker', zLOG.INFO,
                        "Crawling site - commited after %d objects of type %s"
                        % (i, type))
            transaction.commit()
        # Remove unused urls
        database.cleanup()
    finally:
        server.setClientNotifications(True)
Exemple #17
0
    def checkinResource(self, object, message='', user=None):
        """
        Checkin a new version of an object to the repository

        object  : the new object
        message : a string describing the changes
        user    : the name of the user creating the new version
        """

        objectId = object.objectId
        vf = self.getVersionFolder(objectId)
        
        # Initialize history if it doesn't exist yet
        if not vf.objectIds():
            version = "1.1"
            addLatestReference(vf, 'latest', '', version)
        else:
            # Sanity check: if latest version isn't the base of these changes, it's a problem
            # if not self.isLatestVersion(object):
            version = object.getVersion()
            if (version != vf.latest.getVersion()):
                raise CommitError, "Version mismatch: version %s checked out, but latest is %s" % (version, vf.latest.getVersion())
            version = incrementMinor(version)
            
        # Clone the object as a new revision of this collection
        #self._log("Cloning %s" % obj, zLOG.INFO)
        zLOG.LOG("VersionFolder", zLOG.INFO, "Cloning %s (%s)" % (object, self.REQUEST['PATH_INFO']))
        vf.manage_clone(object, version)
        clone = getattr(vf, version)

        # Explicity set repository/versioning metadata
        # FIXME: This should be taken care of by the workflow tool
        try:
            clone.setVersion(version)
        except AttributeError:
            clone.version = version
        try:
            clone.setRevised(DateTime())
        except AttributeError:
            clone.revised = DateTime()
        clone.submitter = user
        clone.submitlog = message
        # The state must be public so the object uses the correct method for viewing (ewwww!)
        clone.state = 'public'

        # Reset the 'latest' reference
        vf.latest.edit(clone.Title(), version)
        self.catalog.catalog_object(vf.latest)

        #Push metadata into DB
        self.portal_moduledb.insertModuleVersion(clone)

        # Generate collxml and stuff it into the DB as well
        xml = clone.restrictedTraverse('source_create')()
        # We know this will be a new file, so just insert it.
        res = self.portal_moduledb.sqlInsertFile(file = Binary(xml), media_type='text/xml')
        fid = res[0].fileid
        # This step depends on the InsertModuleVersion call, above
        self.portal_moduledb.sqlInsertModuleFile(moduleid=clone.objectId, version=clone.version, fileid=fid, filename='collection.xml',mimetype='text/xml')
 def cleanup(self, strFileName):
     # if we are not harvesting the import input file, we are operating on a copy in the temp directory,
     # which needs to be removed after the import has completed.
     bHarvestingOn = ( len(self.config['harvest_dir_success']) > 0 )
     bSaveToTemp = not bHarvestingOn
     if bSaveToTemp:
         zLOG.LOG("OOo2CNXML Transform", zLOG.INFO, "Removing: %s" % strFileName)
         os.remove(strFileName)
Exemple #19
0
 def checkBasics(self):
     self.setLog()
     zLOG.LOG("basic", zLOG.INFO, "summary")
     f = self.getLogFile()
     try:
         self.verifyEntry(f, subsys="basic", summary="summary")
     finally:
         f.close()
Exemple #20
0
    def import_(self, import_context, subdir, root=False):
        """ See IFilesystemImporter.
        """
        context = self.context
        if not root:
            subdir = '%s/%s' % (subdir, context.getId())

        prop_adapter = queryAdapter(context, IINIAware, None)

        if prop_adapter is not None:
            prop_text = import_context.readDataFile('.properties',
                                                    subdir=subdir,
                                                   )
            if prop_text is not None:
                prop_adapter.put_ini(prop_text)

        preserve = import_context.readDataFile('.preserve', subdir)
        must_preserve = self._mustPreserve()

        prior = context.objectIds()

        if not preserve:
            preserve = []
        else:
            preserve = _globtest(preserve, prior)

        preserve.extend([x[0] for x in must_preserve])

        for id in prior:
            if id not in preserve:
                context._delObject(id)

        objects = import_context.readDataFile('.objects', subdir)
        if objects is None:
            return

        dialect = 'excel'
        stream = StringIO(objects)

        rowiter = reader(stream, dialect)

        existing = context.objectIds()

        for object_id, type_name in rowiter:

            if object_id not in existing:
                object = self._makeInstance(object_id, type_name,
                                            subdir, import_context)
                if object is None:
                    zLOG.LOG('SFWA', zLOG.WARNING, 
                             "Couldn't make instance: %s/%s" %
                                   (subdir, object_id))
                    continue

            wrapped = context._getOb(object_id)

            adapter = getAdapter(wrapped, IFilesystemImporter)
            adapter.import_(import_context, subdir)
Exemple #21
0
    def get_report(self, forms, portals='', exclude=False, REQUEST=None):
        if not REQUEST.has_key('show_report'): # TODO: remove this
            return

        report = {}
        forms = convertLinesToList(forms)
        portals_list = get_portals(self)
        portals_custom = []

        if portals.strip():
            for portal_id in portals.split(','):
                portals_custom.append(portal_id.strip())

        for portal in portals_list:
            if portals_custom:
                if exclude and portal.id in portals_custom: continue
                elif not exclude and portal.id not in portals_custom: continue

            portal_path = '/'.join(portal.getPhysicalPath()[1:])
            portal_forms = portal.portal_forms
            if forms:
                forms_list_tmp = []
                for form_line in forms: #Search in ZMI and FS for template patterns
                    for form_id in self.find_templates(re.compile(form_line), portal):
                        if form_id not in forms_list_tmp: forms_list_tmp.append(form_id)
                forms_list = forms_list_tmp
                del(forms_list_tmp)
            else:
                forms_list = portal_forms.objectIds()
            deltas = []

            for form_id in forms_list:
                try:
                    form_fs = portal_forms._default_form(form_id)
                except KeyError, exc_error:
                    zLOG.LOG('Naaya Updater', zLOG.ERROR, '%s: %s' % (portal.id, exc_error))
                    continue
                form_zmi = portal_forms._getOb(form_id)
                if form_fs and form_zmi:
                    t1 = normalize_template(form_fs._text)
                    t2 = normalize_template(form_zmi._text)
                    delta = {
                        'physical_path': '/'.join(form_zmi.getPhysicalPath()[1:]),
                        'absolute_url': form_zmi.absolute_url(),
                        'id': form_zmi.getId(),
                        'title': form_zmi.title_or_id(),
                    }
                    if t1 == t2:
                        delta['result'] = 'identical'
                    else:
                        delta['result'] = 'different'

                        delta['diff'] = html_diff(form_fs._text, form_zmi._text)
                    deltas.append(delta)

            if len(deltas) > 0:
                report[portal_path] = deltas
Exemple #22
0
    def checkDetail(self):
        self.setLog()
        zLOG.LOG("basic", zLOG.INFO, "xxx", "this is a detail")

        f = self.getLogFile()
        try:
            self.verifyEntry(f, subsys="basic", detail="detail")
        finally:
            f.close()
Exemple #23
0
def logZLog(level, label, data, stack):
    """logZLog : writes data though Zope's logging facility
    """
    zLOG.LOG(
        "IngeniWeb",
        zLogLevelConverter[level],
        "",
        data + "\n",
    )
Exemple #24
0
 def handle_RETR(self, cmd, args, firstline, resp):
     if not resp:
         return firstline, resp
     try:
         msg = email.message_from_string(resp)
     except email.Errors.MessageParseError, err:
         zLOG.LOG("POP3", zLOG.WARNING,
                  "Failed to parse msg: %s" % err, error=sys.exc_info())
         resp = self.message_parse_error(resp)
Exemple #25
0
 def import_(self, import_context, subdir, root=False):
     """ See IFilesystemImporter.
     """
     cid = self.context.getId()
     data = import_context.readDataFile('%s.ini' % cid, subdir)
     if data is None:
         zLOG.LOG('SGAIFA', zLOG.INFO,
                  'no .ini file for %s/%s' % (subdir, cid))
     else:
         self.context.put_ini(data)
Exemple #26
0
    def deleteItems(self, ids=[], REQUEST=None):
        """ Delete items (e.g. widgets, reports) by ids"""
        if not ids:
            self.setSessionErrorsTrans(
                'Please select one or more items to delete.')
        else:
            try:
                if isinstance(self._getOb(ids[0]), AVAILABLE_WIDGETS):
                    for widget_id in ids:
                        if (getattr(self._getOb(widget_id), 'locked', '')
                                and not self.checkPermission(
                                    'View Management Screens')):
                            raise Unauthorized

                    # if we're deleting questions, delete the
                    # corresponding statistics too
                    for report in self.getReports():
                        statistic_ids = [
                            stat.id for stat in report.getStatistics()
                            if stat.question.id in ids
                        ]
                        report.manage_delObjects(statistic_ids)
                self.manage_delObjects(ids)
            except Unauthorized:
                err = sys.exc_info()
                zLOG.LOG('Naaya Survey Tool',
                         zLOG.ERROR,
                         'Could not delete items',
                         error=err)
                self.setSessionErrorsTrans(
                    'You are not authorized to delete selected items.')
            except:
                err = sys.exc_info()
                zLOG.LOG('Naaya Survey Tool',
                         zLOG.ERROR,
                         'Could not delete items',
                         error=err)
                self.setSessionErrorsTrans('Error while deleting data.')
            else:
                self.setSessionInfoTrans('Item(s) deleted.')
        if REQUEST:
            return REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
Exemple #27
0
 def import_(self, import_context, subdir, root=False):
     """ See IFilesystemImporter.
     """
     cid = self.context.getId()
     data = import_context.readDataFile('%s.csv' % cid, subdir)
     if data is None:
         zLOG.LOG('CSAFA', zLOG.INFO, 
                          'no .csv file for %s/%s' % (subdir, cid))
     else:
         stream = StringIO(data)
         self.context.put_csv(stream)
Exemple #28
0
def customizeSkins(self, portal):
    skinstool = getToolByName(portal, 'portal_skins')

    # We need to add Filesystem Directory Views for any directories
    # in our skins/ directory.  These directories should already be
    # configured.
    addDirectoryViews(skinstool, 'skins', product_globals)
    zLOG.LOG("CNXSitePolicy", zLOG.INFO,
             "Added 'CNXPloneSite' directory view to portal_skins")

    # FIXME: we need a better way of constructing this
    pathlist = [p.strip() for p in skinstool.getSkinPath('Rhaptos').split(',')]
    pathlist.insert(1, 'CNXPloneSite')
    pathlist.insert(1, 'cnx_overrides')
    path = ','.join(pathlist)

    # Create a new 'Connexions' skin
    skinstool.addSkinSelection('Connexions', path, make_default=1)
    zLOG.LOG("CNXSitePolicy", zLOG.INFO,
             "Added 'Connexions' as new default skin")
Exemple #29
0
 def handle(self):
     zLOG.LOG("POP3", zLOG.INFO,
              "Connection from %s" % repr(self.client_address))
     self.server.zodb.sync()
     self.sess_retr_count = 0
     self.wfile.write("+OK pspam/pop %s\r\n" % VERSION)
     # First read the USER command to get the real server's name
     if not self.read_user():
         zLOG.LOG("POP3", zLOG.INFO, "Did not get valid USER")
         return
     try:
         self.handle_pop()
     finally:
         self.close_pop()
         if self.sess_retr_count == 1:
             ending = ""
         else:
             ending = "s"
         zLOG.LOG("POP3", zLOG.INFO,
                  "Ending session (%d message%s retrieved)"
                  % (self.sess_retr_count, ending))
Exemple #30
0
 def import_(self, import_context, subdir, root=False):
     """ See IFilesystemImporter.
     """
     cid = self.context.getId()
     data = import_context.readDataFile(self._getFileName(), subdir)
     if data is None:
         zLOG.LOG('SGAIFA', zLOG.INFO,
                  'no .ini file for %s/%s' % (subdir, cid))
     else:
         request = FauxDAVRequest(BODY=data, BODYFILE=StringIO(data))
         response = FauxDAVResponse()
         self.context.PUT(request, response)