diff --git a/Products/PloneSoftwareCenter/Extensions/Migrations.py b/Products/PloneSoftwareCenter/Extensions/Migrations.py index b7ca371..b2e0406 100644 --- a/Products/PloneSoftwareCenter/Extensions/Migrations.py +++ b/Products/PloneSoftwareCenter/Extensions/Migrations.py @@ -1,19 +1,17 @@ +from StringIO import StringIO + +from Acquisition import aq_base +from DateTime import DateTime +from Products.Archetypes import transaction +from Products.CMFCore.utils import getToolByName + try: - from Products.contentmigration.migrator import InlineFieldActionMigrator, BaseInlineMigrator + from Products.contentmigration.migrator import BaseInlineMigrator from Products.contentmigration.walker import CustomQueryWalker haveContentMigrations = True except ImportError: haveContentMigrations = False -import types - -from StringIO import StringIO -from Products.CMFCore.utils import getToolByName -from Products.Archetypes import transaction -from Products.CMFPlone.utils import safe_hasattr - -from Acquisition import aq_base -from DateTime import DateTime def v1beta7_v1beta8(self, out): """Migrate from beta 7 to beta 8 diff --git a/Products/PloneSoftwareCenter/Extensions/migrateratings.py b/Products/PloneSoftwareCenter/Extensions/migrateratings.py index ac4df41..7c0ef3e 100644 --- a/Products/PloneSoftwareCenter/Extensions/migrateratings.py +++ b/Products/PloneSoftwareCenter/Extensions/migrateratings.py @@ -7,40 +7,39 @@ class RatingsMigrator(BaseInlineMigrator): - """ - Migrate PSC Projects from the content ratings product to the twothumbs product - """ + """ + Migrate PSC Projects from the content ratings product to the twothumbs product + """ - src_portal_type = src_meta_type = 'PSCProject' + src_portal_type = src_meta_type = 'PSCProject' - def migrate_ratings(self): + def migrate_ratings(self): - """ - contentratings and twothumbs both use annotations. Just want to move - one to another. Here we say anything >= 3 rating is a thumbs up - """ + """ + contentratings and twothumbs both use annotations. Just want to move + one to another. Here we say anything >= 3 rating is a thumbs up + """ - from cioppino.twothumbs import rate as thumbrate + from cioppino.twothumbs import rate as thumbrate - transaction.begin() - item = self.obj - annotations = IAnnotations(item) - if annotations: - if annotations.has_key('contentratings.userrating.psc_stars'): - ratings = annotations['contentratings.userrating.psc_stars'].all_user_ratings() - annotations = thumbrate.setupAnnotations(item) - for rating in ratings: - userid = rating.userid - value = rating._rating + transaction.begin() + item = self.obj + annotations = IAnnotations(item) + if annotations: + if 'contentratings.userrating.psc_stars' in annotations: + ratings = annotations['contentratings.userrating.psc_stars'].all_user_ratings() + annotations = thumbrate.setupAnnotations(item) + for rating in ratings: - if rating >= 3.0: - thumbrate.loveIt(item, rating.userid) - else: - thumbrate.hateIt(item,rating.userid) + if rating >= 3.0: + thumbrate.loveIt(item, rating.userid) + else: + thumbrate.hateIt(item, rating.userid) + + # we need to reindex th object anyways + item.reindexObject() + transaction.commit() - # we need to reindex th object anyways - item.reindexObject() - transaction.commit() def migrate(self): out = StringIO() @@ -49,9 +48,9 @@ def migrate(self): portal_url = getToolByName(self, 'portal_url') portal = portal_url.getPortalObject() - # Migrate release count variable - walker = CustomQueryWalker(portal, RatingsMigrator, query = {'portal_type':'PSCProject'}) + walker = CustomQueryWalker(portal, RatingsMigrator, + query = {'portal_type': 'PSCProject'}) transaction.savepoint(optimistic=True) print >> out, "Switching from contentratings to twothumbs.." walker.go(out=out) diff --git a/Products/PloneSoftwareCenter/__init__.py b/Products/PloneSoftwareCenter/__init__.py index 07bd926..ba5c1be 100644 --- a/Products/PloneSoftwareCenter/__init__.py +++ b/Products/PloneSoftwareCenter/__init__.py @@ -1,20 +1,14 @@ -""" -$Id$ -""" - -from Products.CMFCore.utils import ContentInit -from Products.CMFCore.DirectoryView import registerDirectory - from Products.Archetypes.atapi import listTypes, process_types +from Products.CMFCore import permissions as cmf_permissions +from Products.CMFCore.DirectoryView import registerDirectory +from Products.CMFCore.utils import ContentInit +from Products.validation import validation +from zope.i18nmessageid import MessageFactory from Products.PloneSoftwareCenter import config from Products.PloneSoftwareCenter import permissions as psc_permissions -from Products.CMFCore import permissions - -from Products.validation import validation from Products.PloneSoftwareCenter import validators -from zope.i18nmessageid import MessageFactory PSCMessageFactory = MessageFactory('plonesoftwarecenter') validation.register(validators.ProjectIdValidator('isNonConflictingProjectId')) @@ -26,6 +20,7 @@ def initialize(context): # Kick content registration and sys.modules mangling from Products.PloneSoftwareCenter import content + content # pyflakes allTypes = listTypes(config.PROJECTNAME) @@ -76,7 +71,7 @@ def initialize(context): ContentInit( config.PROJECTNAME + ' Project Content', content_types=tuple(member_content_types), - permission=permissions.AddPortalContent, + permission=cmf_permissions.AddPortalContent, extra_constructors=tuple(member_constructors), fti=ftis, ).initialize(context) diff --git a/Products/PloneSoftwareCenter/browser/category.py b/Products/PloneSoftwareCenter/browser/category.py index 3a7a579..d18b2ea 100644 --- a/Products/PloneSoftwareCenter/browser/category.py +++ b/Products/PloneSoftwareCenter/browser/category.py @@ -1,6 +1,6 @@ -from Products.Five.browser import BrowserView +from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner + class CategoryView(BrowserView): @@ -21,10 +21,11 @@ def get_products(self, category, version, sort_on, SearchableText=None): if sort_on == 'featured': featured = True sort_on = 'positive_ratings' - contentFilter = {'SearchableText': SearchableText, - 'portal_type': 'PSCProject', - 'sort_on' : sort_on, - 'sort_order': 'reverse'} + contentFilter = { + 'SearchableText': SearchableText, + 'portal_type': 'PSCProject', + 'sort_on': sort_on, + 'sort_order': 'reverse'} if version != 'any': contentFilter['getCompatibility'] = version diff --git a/Products/PloneSoftwareCenter/browser/docfolder.py b/Products/PloneSoftwareCenter/browser/docfolder.py index c6d9aae..4378e2e 100644 --- a/Products/PloneSoftwareCenter/browser/docfolder.py +++ b/Products/PloneSoftwareCenter/browser/docfolder.py @@ -1,6 +1,6 @@ -from Products.Five.browser import BrowserView +from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner + class DocFolderView(BrowserView): @@ -28,4 +28,5 @@ def non_phc_contents(self): if not nonPHCTypes: return [] - return self.context.getFolderContents(contentFilter = {'portal_type' : nonPHCTypes}) + return self.context.getFolderContents( + contentFilter={'portal_type': nonPHCTypes}) diff --git a/Products/PloneSoftwareCenter/browser/downloadablefile.py b/Products/PloneSoftwareCenter/browser/downloadablefile.py index b21e627..540835a 100644 --- a/Products/PloneSoftwareCenter/browser/downloadablefile.py +++ b/Products/PloneSoftwareCenter/browser/downloadablefile.py @@ -1,8 +1,8 @@ -from Products.Five.browser import BrowserView +import re + +from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner -import re class DownloadableFileView(BrowserView): @@ -24,7 +24,7 @@ def downloadicon_name(self): (including whitespace) converted to underscores. """ return 'platform_%s.gif' % \ - re.sub(r'\W', '_', self.context.getPlatform()).lower() + re.sub(r'\W', '_', self.context.getPlatform()).lower() def file_size(self): """Return the file size of the download, or None if unknown. diff --git a/Products/PloneSoftwareCenter/browser/filelink.py b/Products/PloneSoftwareCenter/browser/filelink.py index dc48d4b..eb49ba8 100644 --- a/Products/PloneSoftwareCenter/browser/filelink.py +++ b/Products/PloneSoftwareCenter/browser/filelink.py @@ -1,8 +1,8 @@ -from Products.Five.browser import BrowserView +import re + +from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner -import re class FileLinkView(BrowserView): @@ -24,7 +24,7 @@ def downloadicon_name(self): (including whitespace) converted to underscores. """ return 'platform_%s.gif' % \ - re.sub(r'\W', '_', self.context.getPlatform()).lower() + re.sub(r'\W', '_', self.context.getPlatform()).lower() def file_size(self): """Return the file size of the download, or None if unknown. diff --git a/Products/PloneSoftwareCenter/browser/improvement.py b/Products/PloneSoftwareCenter/browser/improvement.py index a2ccf9d..fd397f1 100644 --- a/Products/PloneSoftwareCenter/browser/improvement.py +++ b/Products/PloneSoftwareCenter/browser/improvement.py @@ -1,6 +1,6 @@ -from Products.Five.browser import BrowserView +from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner + class ImprovementView(BrowserView): diff --git a/Products/PloneSoftwareCenter/browser/project.py b/Products/PloneSoftwareCenter/browser/project.py index 0c4d898..b0d160d 100644 --- a/Products/PloneSoftwareCenter/browser/project.py +++ b/Products/PloneSoftwareCenter/browser/project.py @@ -1,6 +1,5 @@ -from Products.Five.browser import BrowserView +from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner def _upcoming_releases(proj): @@ -11,11 +10,11 @@ def _upcoming_releases(proj): releaseFolder = proj.getReleaseFolder() catalog = getToolByName(proj, 'portal_catalog') res = catalog.searchResults( - portal_type = 'PSCRelease', - review_state = ['pre-release', 'alpha', 'beta', 'release-candidate'], - path = '/'.join(releaseFolder.getPhysicalPath()), - sort_on = 'effective', - sort_order = 'reverse') + portal_type = 'PSCRelease', + review_state = ['pre-release', 'alpha', 'beta', 'release-candidate'], + path = '/'.join(releaseFolder.getPhysicalPath()), + sort_on = 'effective', + sort_order = 'reverse') return [r.getObject() for r in res] @@ -44,11 +43,11 @@ def latest_release(self): if releaseFolder: catalog = getToolByName(self.context, 'portal_catalog') res = catalog.searchResults( - path = '/'.join(releaseFolder.getPhysicalPath()), - review_state = 'final', - sort_on = 'Date', - sort_order = 'reverse', - portal_type = 'PSCRelease') + path = '/'.join(releaseFolder.getPhysicalPath()), + review_state = 'final', + sort_on = 'Date', + sort_order = 'reverse', + portal_type = 'PSCRelease') if not res: return None @@ -61,7 +60,6 @@ def latest_release_date(self): latest_release = self.latest_release() - if latest_release: return self.context.toLocalizedTime(latest_release.effective()) else: @@ -73,7 +71,6 @@ def upcoming_releases(self): return _upcoming_releases(self.context) - def all_releases(self): """Get a list of all releases, ordered by version, starting with the latest. """ @@ -81,10 +78,10 @@ def all_releases(self): releaseFolder = proj.getReleaseFolder() catalog = getToolByName(proj, 'portal_catalog') res = catalog.searchResults( - portal_type = 'PSCRelease', - path = '/'.join(releaseFolder.getPhysicalPath()), - sort_on = 'id', - sort_order = 'reverse') + portal_type = 'PSCRelease', + path = '/'.join(releaseFolder.getPhysicalPath()), + sort_on = 'id', + sort_order = 'reverse') return [r.getObject() for r in res] def release_rss_url(self): @@ -94,15 +91,15 @@ def release_rss_url(self): here_url = self.context.absolute_url() req_vars = [ - ['portal_type', 'PSCRelease'], - ['sort_on', 'Date'], - ['sort_order', 'reverse'], - ['path', self.context_path], - ] + ['portal_type', 'PSCRelease'], + ['sort_on', 'Date'], + ['sort_order', 'reverse'], + ['path', self.context_path], + ] req_vars_str = '&'.join( - ['%s=%s' % (pair[0], pair[1]) for pair in req_vars] - ) + ['%s=%s' % (pair[0], pair[1]) for pair in req_vars] + ) return '%s/search_rss?%s' % (here_url, req_vars_str) @@ -123,13 +120,13 @@ def similar_search_url(self): """ req_vars = [ - ['portal_type%3Alist', 'PSCProject'], - ['Creator', self.context.Creator()], - ] + ['portal_type%3Alist', 'PSCProject'], + ['Creator', self.context.Creator()], + ] req_vars_str = '&'.join( - ['%s=%s' % (pair[0], pair[1]) for pair in req_vars] - ) + ['%s=%s' % (pair[0], pair[1]) for pair in req_vars] + ) return '%s/search?%s' % (self.portal_url, req_vars_str) @@ -145,17 +142,16 @@ def release_folder_url(self): """ ids = self.context.contentIds( - filter = {'portal_type': 'PSCReleaseFolder'}) + filter = {'portal_type': 'PSCReleaseFolder'}) if ids: return '%s/%s' % (self.context.absolute_url(), ids[0]) - def roadmap_folder_url(self): """Get the url to the roadmap folder, or None if it does not exist """ ids = self.context.contentIds( - filter = {'portal_type': 'PSCImprovementProposalFolder'}) + filter = {'portal_type': 'PSCImprovementProposalFolder'}) if ids: return '%s/%s' % (self.context.absolute_url(), ids[0]) @@ -171,7 +167,7 @@ def documentation_url(self): """ ids = self.context.contentIds( - filter = {'portal_type': 'PSCDocumentationFolder'}) + filter = {'portal_type': 'PSCDocumentationFolder'}) if ids: return '%s/documentation' % self.context.absolute_url() elif self.context.getDocumentationLink(): @@ -196,8 +192,8 @@ def additional_resources(self, ignore = ('PSCDocumentationFolder',)): ignored types passed in. This essentially allows access to contained help-center items, collectors etc. """ - return [o for o in self.context.folderlistingFolderContents() \ - if o.portal_type not in ignore] + return [o for o in self.context.folderlistingFolderContents() + if o.portal_type not in ignore] def criteria_info(self): """ @@ -242,4 +238,3 @@ def has_review_comment(self): return False except KeyError: return False - diff --git a/Products/PloneSoftwareCenter/browser/projectdoap.py b/Products/PloneSoftwareCenter/browser/projectdoap.py index 04ccdae..5219e61 100644 --- a/Products/PloneSoftwareCenter/browser/projectdoap.py +++ b/Products/PloneSoftwareCenter/browser/projectdoap.py @@ -1,12 +1,9 @@ -from Products.Five.browser import BrowserView -from Products.CMFCore.utils import getToolByName +from xml.dom import getDOMImplementation + from Products.PloneSoftwareCenter.interfaces import ISoftwareCenterContent -from Acquisition import aq_inner, aq_parent, aq_self -from DateTime import DateTime from project import ProjectView -from xml.dom import * class ProjectDOAPView(ProjectView): diff --git a/Products/PloneSoftwareCenter/browser/pypi.py b/Products/PloneSoftwareCenter/browser/pypi.py index 9467521..cf0ed30 100644 --- a/Products/PloneSoftwareCenter/browser/pypi.py +++ b/Products/PloneSoftwareCenter/browser/pypi.py @@ -1,31 +1,28 @@ """ $Id: PyPI.py 18612 2006-01-28 14:46:00Z dreamcatcher $ """ -import re + import hashlib -from decimal import Decimal, InvalidOperation +import re -from AccessControl import getSecurityManager from AccessControl import Unauthorized +from AccessControl import getSecurityManager from AccessControl.SpecialUsers import nobody -import transaction - -from Products.CMFCore.utils import getToolByName -from Products.CMFCore.utils import SimpleItemWithProperties, UniqueObject +from Products.Archetypes.event import ObjectEditedEvent from Products.CMFCore.WorkflowCore import WorkflowException +from Products.CMFCore.utils import getToolByName from Products.Five import BrowserView -from Products.Archetypes.event import ObjectEditedEvent - -from Products.PloneSoftwareCenter.utils import VersionPredicate -from Products.PloneSoftwareCenter.utils import which_platform -from Products.PloneSoftwareCenter.utils import is_distutils_file -from Products.PloneSoftwareCenter.utils import get_projects_by_distutils_ids - +from decimal import Decimal, InvalidOperation from plone.i18n.normalizer.interfaces import IFileNameNormalizer - from zope.annotation.interfaces import IAnnotations from zope.component import queryUtility from zope.event import notify +import transaction + +from Products.PloneSoftwareCenter.utils import VersionPredicate +from Products.PloneSoftwareCenter.utils import get_projects_by_distutils_ids +from Products.PloneSoftwareCenter.utils import is_distutils_file +from Products.PloneSoftwareCenter.utils import which_platform safe_filenames = re.compile(r'.+?\.(exe|tar\.gz|bz2|egg|rpm|deb|zip|tgz)$', re.I) @@ -158,7 +155,6 @@ def _is_published(self, project): def _store_package(self, name, version, data): msg = [] user = getSecurityManager().getUser() - sc = self.context normalized_name = self.normalizeName(name) # getting project and release packages. @@ -341,7 +337,7 @@ def _get_package(self, normalized_name, name, version, msg=None): releases.invokeFactory('PSCRelease', id=version) try: IAnnotations(releases[version])['title_hint'] = name - except TypeError, KeyError: + except (TypeError, KeyError): pass if msg is not None: msg.append('Created Release %s in Project %s' % \ @@ -469,7 +465,7 @@ def file_upload(self, data=None): return self.fail(err) md5_digest = data.get('md5_digest') - comment = data.get('comment') + #comment = data.get('comment') # check for valid filenames filename = content.filename diff --git a/Products/PloneSoftwareCenter/browser/releasefolder.py b/Products/PloneSoftwareCenter/browser/releasefolder.py index 76ee841..18a403c 100644 --- a/Products/PloneSoftwareCenter/browser/releasefolder.py +++ b/Products/PloneSoftwareCenter/browser/releasefolder.py @@ -1,9 +1,9 @@ -from Products.Five.browser import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner +from Products.Five import BrowserView from Products.PloneSoftwareCenter.browser.project import _upcoming_releases + class ReleaseFolderView(BrowserView): def __init__(self, context, request): @@ -31,4 +31,3 @@ def previous_releases(self): sort_on = 'effective', sort_order = 'reverse') return [r.getObject() for r in res] - diff --git a/Products/PloneSoftwareCenter/browser/roadmap.py b/Products/PloneSoftwareCenter/browser/roadmap.py index a1425e9..ad5d120 100644 --- a/Products/PloneSoftwareCenter/browser/roadmap.py +++ b/Products/PloneSoftwareCenter/browser/roadmap.py @@ -1,9 +1,9 @@ -from Products.Five.browser import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner +from Products.Five import BrowserView from Products.PloneSoftwareCenter.browser.project import _upcoming_releases + class RoadmapView(BrowserView): def __init__(self, context, request): @@ -23,9 +23,9 @@ def state_title(self, state): return wf.states[state].title return self.context.utranslate( - msgid='workflow_state_title_%s' % state, - domain='plonesoftwarecenter', - default=wf.states[state].title) + msgid='workflow_state_title_%s' % state, + domain='plonesoftwarecenter', + default=wf.states[state].title) def improvement_proposals(self, review_state = []): """Get the improvement proposals in this folder, sorted on plip number, @@ -43,10 +43,14 @@ def improvement_proposals(self, review_state = []): proposals = catalog.portal_catalog(query) def sortProposals(x, y): - try: xval = int(x.getId) - except ValueError: xval = 0 - try: yval = int(y.getId) - except ValueError: yval = 0 + try: + xval = int(x.getId) + except ValueError: + xval = 0 + try: + yval = int(y.getId) + except ValueError: + yval = 0 return cmp(xval, yval) proposals = [p for p in proposals] diff --git a/Products/PloneSoftwareCenter/browser/root.py b/Products/PloneSoftwareCenter/browser/root.py index a4d93c5..5a030eb 100644 --- a/Products/PloneSoftwareCenter/browser/root.py +++ b/Products/PloneSoftwareCenter/browser/root.py @@ -1,8 +1,6 @@ -from urllib import quote - -from Products.Five.browser import BrowserView from Products.CMFCore.utils import getToolByName -from Acquisition import aq_inner +from Products.Five import BrowserView + class SoftwareCenterView(BrowserView): @@ -18,12 +16,12 @@ def __init__(self, context, request): def rss_url(self): """Get the URL to the RSS feed for the project center """ - return "%s/search_rss?" \ - "portal_type=PSCRelease&" \ - "sort_on=Date&sort_order=reverse&"\ - "review_state=alpha&review_state=beta&" \ - "review_state=release-candidate&review_state=final" \ - % self.context.absolute_url() + return ("%s/search_rss?" + "portal_type=PSCRelease&" + "sort_on=Date&sort_order=reverse&" + "review_state=alpha&review_state=beta&" + "review_state=release-candidate&review_state=final" + % self.context.absolute_url()) def active_projects(self): """Get all active projects (i.e. they have one alpha/beta/rc/final @@ -32,7 +30,7 @@ def active_projects(self): return self.catalog(review_state = 'published', portal_type = 'PSCProject', path = self.context_path, - releaseCount = {'query' : 1, 'range' : 'min'}, + releaseCount = {'query': 1, 'range': 'min'}, sort_on = 'sortable_title', sort_order = 'asc') @@ -75,7 +73,6 @@ def parent_url(url): filtered_values = self.catalog.uniqueValuesFor('getClassifiers') field = self.context.getField('availableClassifiers') vocab = self.context.getAvailableTopicsFromClassifiers() - classifiers = field.getAsGrid(self.context) field_name = 'getClassifiers' else: vocab = self.context.getAvailableCategoriesAsDisplayList() @@ -92,28 +89,31 @@ def parent_url(url): "sort_order=reverse&path=%s&getCategories=%s&" "review_state=alpha&review_state=beta&" "review_state=release-candidate&" - "review_state=final") % (self.portal_url, - self.context_path, - cat) + "review_state=final") % (self.portal_url, + self.context_path, + cat) releases = [] - release_query = {'path': self.context_path, - 'portal_type': 'PSCRelease', - field_name: cat, - 'sort_on': 'Date', - 'sort_order': 'reverse', - 'sort_limit': 5} - - project_query = {field_name: cat, - 'portal_type': 'PSCProject', - 'path': self.context_path} + release_query = { + 'path': self.context_path, + 'portal_type': 'PSCRelease', + field_name: cat, + 'sort_on': 'Date', + 'sort_order': 'reverse', + 'sort_limit': 5} + + project_query = { + field_name: cat, + 'portal_type': 'PSCProject', + 'path': self.context_path} for r in self.catalog(**release_query)[:5]: - releases.append(dict(title = r.Title, - description = r.Description, - parent_url = parent_url(r.getURL()), - review_state = r.review_state, - date = r.Date)) + releases.append(dict( + title = r.Title, + description = r.Description, + parent_url = parent_url(r.getURL()), + review_state = r.review_state, + date = r.Date)) num_projects = len(self.catalog(**project_query)) @@ -182,4 +182,3 @@ def project_url(self): return self.context.getField('featuredProject').absolute_url() except: return False - diff --git a/Products/PloneSoftwareCenter/config.py b/Products/PloneSoftwareCenter/config.py index 0b91b4e..e42e2df 100644 --- a/Products/PloneSoftwareCenter/config.py +++ b/Products/PloneSoftwareCenter/config.py @@ -48,6 +48,7 @@ if USE_EXTERNAL_STORAGE: try: import Products.ExternalStorage + Products.ExternalStorage # pyflakes except ImportError: LOG('PloneSoftwareCenter', PROBLEM, 'ExternalStorage N/A, falling back to AttributeStorage') diff --git a/Products/PloneSoftwareCenter/content/docfolder.py b/Products/PloneSoftwareCenter/content/docfolder.py index d1d6abc..a83515b 100644 --- a/Products/PloneSoftwareCenter/content/docfolder.py +++ b/Products/PloneSoftwareCenter/content/docfolder.py @@ -2,29 +2,23 @@ $Id: PSCDocumentationFolder.py 24410 2006-06-05 01:40:27Z optilude $ """ -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IDocumentationFolderContent - from AccessControl import ClassSecurityInfo -from Products.CMFCore import permissions -from Products.CMFCore.utils import getToolByName - -from Products.Archetypes.atapi import * -try: - import transaction -except ImportError: # BBB - from Products.Archetypes import transaction - from Products.ATContentTypes.content.base import ATCTMixin +from Products.Archetypes.atapi import * +from Products.CMFCore import permissions +from zope.interface import implements +import transaction -from Products.PloneSoftwareCenter import PSCMessageFactory as _ -from Products.PloneSoftwareCenter.config import PROJECTNAME, DOCUMENTATION_ID try: from Products.PloneHelpCenter.interfaces import IHelpCenterContent + IHelpCenterContent # pyflakes except ImportError: IHelpCenterContent = None +from Products.PloneSoftwareCenter import PSCMessageFactory as _ +from Products.PloneSoftwareCenter.config import PROJECTNAME, DOCUMENTATION_ID +from Products.PloneSoftwareCenter.interfaces import IDocumentationFolderContent + PSCDocumentationFolderSchema = OrderedBaseFolderSchema.copy() + Schema(( StringField( diff --git a/Products/PloneSoftwareCenter/content/downloadablefile.py b/Products/PloneSoftwareCenter/content/downloadablefile.py index 084afa7..408b066 100644 --- a/Products/PloneSoftwareCenter/content/downloadablefile.py +++ b/Products/PloneSoftwareCenter/content/downloadablefile.py @@ -2,23 +2,17 @@ $Id: PSCFile.py 19225 2006-02-13 05:50:18Z limi $ """ -import re - -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IFileContent - from AccessControl import ClassSecurityInfo -from Products.CMFCore import permissions - +from Products.ATContentTypes.content.base import ATCTFileContent from Products.Archetypes.atapi import * +from Products.CMFCore import permissions +from zope.interface import implements -from Products.PloneSoftwareCenter import config from Products.PloneSoftwareCenter import PSCMessageFactory as _ +from Products.PloneSoftwareCenter import config +from Products.PloneSoftwareCenter.interfaces import IFileContent from Products.PloneSoftwareCenter.storage import DynamicStorage -from Products.ATContentTypes.content.base import ATCTFileContent - # We need to make sure that the right storage is set at Field # creation to correctly trigger the layer registration process #if config.USE_EXTERNAL_STORAGE: diff --git a/Products/PloneSoftwareCenter/content/filelink.py b/Products/PloneSoftwareCenter/content/filelink.py index 42821c3..4d4deaf 100644 --- a/Products/PloneSoftwareCenter/content/filelink.py +++ b/Products/PloneSoftwareCenter/content/filelink.py @@ -2,20 +2,15 @@ $Id: PSCFileLink.py 19225 2006-02-13 05:50:18Z limi $ """ -import re - -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IFileLinkContent - from AccessControl import ClassSecurityInfo -from Products.CMFCore import permissions - -from Products.Archetypes.atapi import * from Products.ATContentTypes.content.base import ATCTMixin +from Products.Archetypes.atapi import * +from Products.CMFCore import permissions +from zope.interface import implements from Products.PloneSoftwareCenter import PSCMessageFactory as _ from Products.PloneSoftwareCenter.config import PROJECTNAME +from Products.PloneSoftwareCenter.interfaces import IFileLinkContent PSCFileLinkSchema = BaseSchema.copy() + Schema(( diff --git a/Products/PloneSoftwareCenter/content/proposal.py b/Products/PloneSoftwareCenter/content/proposal.py index 7fc455f..0613e7c 100644 --- a/Products/PloneSoftwareCenter/content/proposal.py +++ b/Products/PloneSoftwareCenter/content/proposal.py @@ -2,25 +2,16 @@ $Id: PSCImprovementProposal.py 24697 2006-06-10 22:01:35Z optilude $ """ -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IImprovementProposalContent - from AccessControl import ClassSecurityInfo - -from Products.CMFCore import permissions - -from Products.Archetypes.atapi import * - -try: - import transaction -except ImportError: # BBB - from Products.Archetypes import transaction - from Products.ATContentTypes.content.base import ATCTMixin +from Products.Archetypes.atapi import * +from Products.CMFCore import permissions +from zope.interface import implements +import transaction from Products.PloneSoftwareCenter import PSCMessageFactory as _ from Products.PloneSoftwareCenter.config import PROJECTNAME +from Products.PloneSoftwareCenter.interfaces import IImprovementProposalContent TEXT_TYPES = ( 'text/structured', diff --git a/Products/PloneSoftwareCenter/content/proposalfolder.py b/Products/PloneSoftwareCenter/content/proposalfolder.py index f0eaaa1..34e9ef6 100644 --- a/Products/PloneSoftwareCenter/content/proposalfolder.py +++ b/Products/PloneSoftwareCenter/content/proposalfolder.py @@ -2,27 +2,15 @@ $Id: PSCImprovementProposalFolder.py 24400 2006-06-04 22:38:43Z optilude $ """ -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IImprovementProposalFolderContent - from AccessControl import ClassSecurityInfo - -from Products.CMFCore import permissions - -from Products.Archetypes.atapi import * - -try: - import transaction -except ImportError: # BBB - from Products.Archetypes import transaction - from Products.ATContentTypes.content.base import ATCTMixin +from Products.Archetypes.atapi import * +from zope.interface import implements +import transaction from Products.PloneSoftwareCenter import PSCMessageFactory as _ from Products.PloneSoftwareCenter.config import PROJECTNAME, IMPROVEMENTS_ID - -from Products.CMFCore.utils import getToolByName +from Products.PloneSoftwareCenter.interfaces import IImprovementProposalFolderContent PSCImprovementProposalFolderSchema = OrderedBaseFolderSchema.copy() + Schema(( diff --git a/Products/PloneSoftwareCenter/content/release.py b/Products/PloneSoftwareCenter/content/release.py index c4a8c26..2db7ae5 100644 --- a/Products/PloneSoftwareCenter/content/release.py +++ b/Products/PloneSoftwareCenter/content/release.py @@ -2,32 +2,18 @@ $Id: PSCRelease.py 24703 2006-06-11 01:44:04Z optilude $ """ -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IReleaseContent - -import re - -from random import random -from DateTime import DateTime - -from Acquisition import aq_inner -from Acquisition import aq_parent - from AccessControl import ClassSecurityInfo -from Products.CMFCore import permissions -from Products.CMFCore.utils import getToolByName - -from Products.Archetypes.atapi import * from Products.ATContentTypes.content.base import ATCTMixin - from Products.AddRemoveWidget import AddRemoveWidget +from Products.Archetypes.atapi import * +from Products.CMFCore import permissions +from Products.CMFCore.utils import getToolByName +from zope.annotation.interfaces import IAnnotations +from zope.interface import implements from Products.PloneSoftwareCenter import PSCMessageFactory as _ from Products.PloneSoftwareCenter import config - -from zope.annotation.interfaces import IAnnotations - +from Products.PloneSoftwareCenter.interfaces import IReleaseContent PSCReleaseSchema = OrderedBaseFolderSchema.copy() + Schema(( @@ -257,6 +243,7 @@ PSCReleaseSchema.moveField('releaseNumber', before='description') + class PSCRelease(ATCTMixin, OrderedBaseFolder): """A release of a software project, either final or in progress""" diff --git a/Products/PloneSoftwareCenter/content/releasefolder.py b/Products/PloneSoftwareCenter/content/releasefolder.py index a8f95b9..60d23ad 100644 --- a/Products/PloneSoftwareCenter/content/releasefolder.py +++ b/Products/PloneSoftwareCenter/content/releasefolder.py @@ -2,24 +2,16 @@ $Id: PSCReleaseFolder.py 24400 2006-06-04 22:38:43Z optilude $ """ -from zope.interface import implements - -from Products.PloneSoftwareCenter.interfaces import IReleaseFolderContent - from AccessControl import ClassSecurityInfo -from Products.CMFCore import permissions -from Products.CMFCore.utils import getToolByName - -from Products.Archetypes.atapi import * -try: - import transaction -except ImportError: # BBB - from Products.Archetypes import transaction - from Products.ATContentTypes.content.base import ATCTMixin +from Products.Archetypes.atapi import * +from Products.CMFCore import permissions +from zope.interface import implements +import transaction -from Products.PloneSoftwareCenter import config from Products.PloneSoftwareCenter import PSCMessageFactory as _ +from Products.PloneSoftwareCenter import config +from Products.PloneSoftwareCenter.interfaces import IReleaseFolderContent PSCReleaseFolderSchema = OrderedBaseFolderSchema.copy() + Schema(( diff --git a/Products/PloneSoftwareCenter/namespace/pypisimple.py b/Products/PloneSoftwareCenter/namespace/pypisimple.py index cfdf315..db357d0 100644 --- a/Products/PloneSoftwareCenter/namespace/pypisimple.py +++ b/Products/PloneSoftwareCenter/namespace/pypisimple.py @@ -7,20 +7,17 @@ import itertools import os -from zope.interface import implements - -from Products.Five import BrowserView from Products.CMFCore.utils import getToolByName - from Products.PloneSoftwareCenter.utils import get_projects_by_distutils_ids - -from zope.publisher.interfaces.browser import IBrowserView +from zope.interface import implements from zope.publisher.interfaces.browser import IBrowserPublisher +from zope.publisher.interfaces.browser import IBrowserView from zope.publisher.interfaces.browser import IPublishTraverse -from zope.traversing.namespace import SimpleHandler from zope.traversing.interfaces import TraversalError +from zope.traversing.namespace import SimpleHandler try: from zope.browserpage.viewpagetemplatefile import ViewPageTemplateFile + ViewPageTemplateFile # pyflakes except ImportError: # bbb: Zope 2.12 and older from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile @@ -34,7 +31,7 @@ class PyPISimpleTraverser(SimpleHandler): def __init__(self, context, request): self.context = context self.request = request - + def __of__(self, context): return self @@ -57,6 +54,7 @@ def __call__(self): SIMPLE = os.path.join(os.path.dirname(__file__), 'pypisimple.pt') PROJECT = os.path.join(os.path.dirname(__file__), 'pypiproject.pt') + class PyPISimpleView(object): """view used for the main package index page""" implements(IBrowserPublisher) @@ -107,10 +105,11 @@ def _filter_id(brain): return itertools.chain(*[self.get_url_and_distutils_ids(p) for p in projects if p is not None]) + class PyPIProjectView(PyPISimpleView): def __init__(self, context, request, name): - PyPISimpleView.__init__(self, context, request) + PyPISimpleView.__init__(self, context, request) self.context = context self.request = request self.project_name = name @@ -163,4 +162,3 @@ def get_links(self): 'rel': field}) return links - diff --git a/Products/PloneSoftwareCenter/storage/archetype.py b/Products/PloneSoftwareCenter/storage/archetype.py index 7a6051b..2761c2d 100644 --- a/Products/PloneSoftwareCenter/storage/archetype.py +++ b/Products/PloneSoftwareCenter/storage/archetype.py @@ -1,10 +1,7 @@ -from zope.interface import implements -from zope.component import adapts - from Products.Archetypes.atapi import AttributeStorage - from Products.PloneSoftwareCenter.storage.interfaces import IPSCFileStorage -from Products.Archetypes.interfaces.storage import IStorage +from zope.interface import implements + class ArchetypeStorage(AttributeStorage): """adapts a release folder as a dummy storage @@ -16,5 +13,3 @@ class ArchetypeStorage(AttributeStorage): def __init__(self, context): self.context = context - - diff --git a/Products/PloneSoftwareCenter/tests/test_project_doap.py b/Products/PloneSoftwareCenter/tests/test_project_doap.py index f5577a4..2006a53 100644 --- a/Products/PloneSoftwareCenter/tests/test_project_doap.py +++ b/Products/PloneSoftwareCenter/tests/test_project_doap.py @@ -12,6 +12,7 @@ from Testing import ZopeTestCase try: from Products.Poi.interfaces import Tracker + Tracker # pyflakes HAS_POI = True ZopeTestCase.installProduct('Poi') except ImportError: diff --git a/Products/PloneSoftwareCenter/tests/utils.py b/Products/PloneSoftwareCenter/tests/utils.py index 52136f4..f29d632 100644 --- a/Products/PloneSoftwareCenter/tests/utils.py +++ b/Products/PloneSoftwareCenter/tests/utils.py @@ -5,9 +5,10 @@ from Products.CMFCore.utils import getToolByName # Standard options for DocTests -optionflags = (doctest.ELLIPSIS | - doctest.NORMALIZE_WHITESPACE | - doctest.REPORT_ONLY_FIRST_FAILURE) +optionflags = (doctest.ELLIPSIS | + doctest.NORMALIZE_WHITESPACE | + doctest.REPORT_ONLY_FIRST_FAILURE) + def verifyURLWithRequestVars(url, base, request_list): request_list = tuple(request_list) @@ -19,9 +20,8 @@ def verifyURLWithRequestVars(url, base, request_list): return False if url.count('?'): - url1, url2 = url.split('?') + _ignored, url2 = url.split('?') else: - url1 = url url2 = '' actual_vars = url2.split('&') @@ -34,13 +34,14 @@ def verifyURLWithRequestVars(url, base, request_list): return actual_vars == [] + def setUpDefaultMembers(portal): - portal_membership = getToolByName(portal, 'portal_membership') membership = getToolByName(portal, 'portal_membership') membership.addMember('member1', 'secret', ['Member'], []) membership.addMember('member2', 'secret', ['Member'], []) membership.addMember('member3', 'secret', ['Member'], []) + def setUpEvaluator(psc, id): roles = list(psc.get_local_roles_for_userid(id)) if 'PSCEvaluator' not in roles: diff --git a/Products/PloneSoftwareCenter/trove.py b/Products/PloneSoftwareCenter/trove.py index fb3322d..df1ec06 100644 --- a/Products/PloneSoftwareCenter/trove.py +++ b/Products/PloneSoftwareCenter/trove.py @@ -2,13 +2,13 @@ Trove reader $Id:$ """ -from urllib2 import urlopen from urllib2 import URLError +from urllib2 import urlopen import socket -from itertools import groupby PYPI_CLASSIFIERS_URL = 'http://pypi.python.org/pypi?%3Aaction=list_classifiers' + class TroveClassifier(object): """PloneSoftware-friendly Trove provider """ @@ -63,4 +63,3 @@ def _sorted(key1, key2): return sorted(['%s|%s|%s' % (value[0], value[1], key) for key, value in self._ids.items()], _sorted) - diff --git a/Products/PloneSoftwareCenter/validators.py b/Products/PloneSoftwareCenter/validators.py index 0690380..b3db828 100644 --- a/Products/PloneSoftwareCenter/validators.py +++ b/Products/PloneSoftwareCenter/validators.py @@ -8,19 +8,20 @@ try: # Plone 4 and higher import plone.app.upgrade + plone.app.upgrade # pyflakes USE_BBB_VALIDATORS = False except ImportError: # BBB Plone 3 USE_BBB_VALIDATORS = True - -from zope.interface import implements +from Products.Archetypes.interfaces import IObjectPreValidation from Products.validation.interfaces.IValidator import IValidator from zope.component import adapts -from Products.Archetypes.interfaces import IObjectPreValidation +from zope.i18nmessageid import MessageFactory +from zope.interface import implements + from Products.PloneSoftwareCenter.interfaces import IProjectContent -from zope.i18nmessageid import MessageFactory _ = MessageFactory('plonesoftwarecenter') is_valid_contact = re.compile('[mailto:,http:]')