Permalink
Browse files

made it work in zope 2.12

  • Loading branch information...
1 parent 2f6fd32 commit 557c628400bfb34ea507e3802e37d2b8570b8a59 @peterbe committed May 1, 2010
View
9 IssueTrackerProduct/Assignment.py
@@ -8,11 +8,16 @@
# python
# Zope
-from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
-from zLOG import LOG, ERROR, INFO, PROBLEM, WARNING
from DateTime import DateTime
+try:
+ # >= Zope 2.12
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import InitializeClass
+
# Product
from Issue import IssueTrackerIssue
from Constants import *
View
3 IssueTrackerProduct/CHANGES.txt
@@ -1,4 +1,7 @@
-
+ New feature: Made IssueTrackerProduct work in Zope 2.12. (Thanks
+ Suresh V)
+
New feature: Now possible to filter by assignees.
New feature: Home page list of recent issues is much optimized by
View
10 IssueTrackerProduct/CustomField.py
@@ -12,13 +12,21 @@
# Zope
from OFS.Folder import Folder
-from Globals import DTMLFile, InitializeClass, DevelopmentMode
+from Globals import DevelopmentMode
from AccessControl import ClassSecurityInfo
from Acquisition import aq_inner, aq_parent, aq_base
from DateTime import DateTime
from DateTime.DateTime import DateError
try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile, InitializeClass
+
+try:
from persistent.mapping import PersistentMapping
except ImportError:
# for old versions of Zope
View
10 IssueTrackerProduct/Datepicker.py
@@ -1,6 +1,14 @@
from AccessControl import ClassSecurityInfo
-from Globals import InitializeClass
+
+try:
+ # >= Zope 2.12
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import InitializeClass
+
+
from Constants import DEFAULT_DATEPICKER_OPTIONS
View
8 IssueTrackerProduct/Email.py
@@ -14,7 +14,13 @@
# Zope
from OFS import SimpleItem
from AccessControl import ClassSecurityInfo
-from Globals import InitializeClass
+
+try:
+ # >= Zope 2.12
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import InitializeClass
# Product
import IssueTracker
View
11 IssueTrackerProduct/Expression.py
@@ -22,12 +22,17 @@
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base, aq_inner, aq_parent
-from Globals import InitializeClass
-from Globals import Persistent
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter
-#from utils import getToolByName
+try:
+ # >= Zope 2.12
+ from Persistence import Persistent
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import Persistent, InitializeClass
+
class Expression (Persistent):
View
13 IssueTrackerProduct/Issue.py
@@ -24,11 +24,18 @@
# Zope
from Acquisition import aq_inner, aq_parent
-from Globals import InitializeClass
from AccessControl import ClassSecurityInfo, getSecurityManager
from zLOG import LOG, ERROR, INFO, PROBLEM, WARNING
from DateTime import DateTime
-from webdav.WriteLockInterface import WriteLockInterface
+
+try:
+ # >= Zope 2.12
+ from webdav.interfaces import IWriteLock
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from webdav.WriteLockInterface import WriteLockInterface as IWriteLock
+ from Globals import InitializeClass
try:
from persistent.mapping import PersistentMapping
@@ -3354,7 +3361,7 @@ class IssueTrackerDraftIssue(IssueTrackerIssue):
It's like the regular Issue objects except that it
doesn't get cataloged. """
- __implements__ = (WriteLockInterface,)
+ __implements__ = (IWriteLock,)
meta_type = ISSUE_DRAFT_METATYPE
icon = '%s/issuedraft.gif'%ICON_LOCATION
View
39 IssueTrackerProduct/IssueTracker.py
@@ -102,7 +102,6 @@
# Zope
from Products.PageTemplates.PageTemplateFile import PageTemplateFile as PTF
-from Globals import Persistent, InitializeClass, package_home, DTMLFile
from OFS import Folder
from DocumentTemplate import sequence
from AccessControl import ClassSecurityInfo, getSecurityManager, AuthEncoding
@@ -116,6 +115,16 @@
from ZPublisher.HTTPRequest import record
from zExceptions import NotFound, Unauthorized
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from Persistence import Persistent
+ from App.class_init import InitializeClass
+ from App.Common import package_home
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile, Persistent, InitializeClass, package_home
+
# Is CMF installed?
try:
@@ -4243,8 +4252,10 @@ def _moveTempfiles(self, destination):
if request.has_key(rkey):
files_copied = []
upload_folder_id = request.get(rkey)
+ if not upload_folder_id:
+ return
if not hasattr(self._getTempFolder(), upload_folder_id):
- return
+ return
upload_folder = self._getTempFolder()[upload_folder_id]
confirms = self._getConfirmFileattachments()
@@ -5759,7 +5770,14 @@ def InitZCatalog(self, t={}):
textindexes = ('email','url2issue')
for idx in textindexes:
if not indexes.has_key(idx):
- zcatalog.addIndex(idx, 'TextIndex')
+ try:
+ zcatalog.addIndex(idx, 'TextIndex')
+ except ValueError:
+ # >= Zope 2.12
+ extras = Empty()
+ extras.index_type = 'Okapi BM25 Rank'
+ extras.lexicon_id = 'Lexicon'
+ zcatalog.addIndex(idx, 'ZCTextIndex', extras)
dateindexes = ['modifydate']
if self.EnableDueDate():
@@ -13072,8 +13090,7 @@ def _check_permission(perm, object, user=security_user):
except:
def _check_permission(*a, **k):
return False
- LOG("standard_error_message", ERROR,
- "_check_permission() function disabled", error=sys.exc_info())
+ logger.error("_check_permission() function disabled", exc_info=True)
try:
if _check_permission(VMS, error_log):
@@ -13082,9 +13099,7 @@ def _check_permission(*a, **k):
file.write(error_log.getLogEntryAsText(id=last_entry.get('id')))
file.write("\n\n")
except:
- LOG("standard_error_message", ERROR,
- "Could not get the last traceback",
- error=sys.exc_info())
+ logger.error("Could not get the last traceback", exc_info=True)
version = self.getIssueTrackerVersion()
file.write("IssueTrackerProduct version: %s\n"%version)
@@ -13112,9 +13127,7 @@ def _check_permission(*a, **k):
temp_folder.manage_addFile(fileid, file=file,
content_type='text/plain')
except:
- LOG("standard_error_message", ERROR,
- "Could not create error file object",
- error=sys.exc_info())
+ logger.error("Could not create error file object", exc_info=True)
return None
fileobject = getattr(temp_folder, fileid)
@@ -13861,8 +13874,8 @@ def manage_deleteIssuesAndThreads(self, issuepaths=[], threadpaths=[],
all = list(dtmls+zpts)
-if not DEBUG:
- all.append('zpt/standard_error_message')
+#if not DEBUG:
+# all.append('zpt/standard_error_message')
addTemplates2Class(IssueTracker, tuple(all))
setattr(IssueTracker, 'About.html', IssueTracker.About)
View
4 IssueTrackerProduct/IssueTrackerNotifyables.py
@@ -1,3 +1,7 @@
+import warnings
+warnings.warn("This file is deprecated in favor of Notifyables.py",
+ DeprecationWarning, 2)
+
# python
from types import ListType
View
10 IssueTrackerProduct/IssueUserFolder.py
@@ -11,10 +11,18 @@
# Zope
from AccessControl import User, AuthEncoding
-from Globals import DTMLFile, MessageDialog, Persistent
+from App.Dialogs import MessageDialog
from AccessControl import ClassSecurityInfo
from AccessControl.Role import DEFAULTMAXLISTUSERS
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from Persistence import Persistent
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile, Persistent
+
# Product
import Utils
from I18N import _
View
9 IssueTrackerProduct/Note.py
@@ -7,12 +7,19 @@
# Zope
from OFS.SimpleItem import SimpleItem
from OFS.PropertyManager import PropertyManager
-from Globals import InitializeClass, DTMLFile
from Products.ZCatalog.CatalogAwareness import CatalogAware
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from Acquisition import aq_inner, aq_parent
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import InitializeClass, DTMLFile
+
# Is CMF installed?
try:
from Products.CMFCore.utils import getToolByName as CMF_getToolByName
View
9 IssueTrackerProduct/Notification.py
@@ -8,13 +8,18 @@
# Zope
-from Globals import InitializeClass
from OFS import SimpleItem
from AccessControl import ClassSecurityInfo
-from zLOG import LOG, ERROR, INFO, PROBLEM, WARNING
from DateTime import DateTime
from Acquisition import aq_inner, aq_parent
+try:
+ # >= Zope 2.12
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import InitializeClass
+
# Product
from IssueTracker import IssueTracker, base_hasattr
View
11 IssueTrackerProduct/Notifyables.py
@@ -4,7 +4,16 @@
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from OFS import SimpleItem, Folder
from AccessControl import ClassSecurityInfo
-from Globals import MessageDialog, InitializeClass, DTMLFile
+from App.Dialogs import MessageDialog
+
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile, InitializeClass
+
# Product
import Utils
View
12 IssueTrackerProduct/ReportScript.py
@@ -18,12 +18,20 @@
# zope
-from Globals import DTMLFile, InitializeClass, package_home
from Products.PythonScripts.PythonScript import PythonScript
from AccessControl import ClassSecurityInfo
from Acquisition import aq_inner, aq_parent
from DateTime import DateTime
-from zLOG import LOG, INFO
+
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from App.class_init import InitializeClass
+ from App.Common import package_home
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile, InitializeClass, package_home
+
from Shared.DC.Scripts.Script import defaultBindings # Script, BindingsUI,
View
8 IssueTrackerProduct/TemplateAdder.py
@@ -107,7 +107,13 @@ def foo(...):
import os
import time
-from Globals import DTMLFile
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile
+
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
try:
View
10 IssueTrackerProduct/Thread.py
@@ -9,11 +9,19 @@
import sys
# Zope
-from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
from zLOG import LOG, ERROR, INFO, PROBLEM, WARNING
from DateTime import DateTime
+try:
+ # >= Zope 2.12
+ from App.special_dtml import DTMLFile
+ from App.class_init import InitializeClass
+except ImportError:
+ # < Zope 2.12
+ from Globals import DTMLFile, InitializeClass
+
+
# Is CMF installed?
try:
from Products.CMFCore.utils import getToolByName as CMF_getToolByName
View
9 IssueTrackerProduct/Utils.py
@@ -33,10 +33,15 @@
from Products.PythonScripts.standard import html_quote, newline_to_br, \
url_quote, url_quote_plus
-from StructuredText.StructuredText import HTML
+try:
+ # >= Zope 2.12
+ from zope.structuredtext import stx2html
+except ImportError:
+ # < Zope 2.12
+ from StructuredText.StructuredText import HTML as stx2html
def structured_text(txt):
- return HTML(txt,
+ return stx2html(txt,
level=int(os.environ.get('STX_DEFAULT_LEVEL',3)),
header=0)
View
23 IssueTrackerProduct/__init__.py
@@ -13,7 +13,7 @@
import IssueTracker
import Thread
import Note
-import IssueTrackerNotifyables as Notifyables
+import Notifyables
import Issue
import Email
import IssueUserFolder
@@ -208,11 +208,26 @@ def registerCSS(filename, **kw):
from App.Common import rfc1123_date
from ZPublisher.Iterators import filestream_iterator
-from Globals import package_home, DevelopmentMode
+from Globals import DevelopmentMode
+
+try:
+ # >= Zope 2.12
+ from App.Common import package_home
+except ImportError:
+ # < Zope 2.12
+ from Globals import package_home
+
+
try:
- from zope.app.content_types import guess_content_type
+ # >= Zope 2.12
+ from zope.contenttype import guess_content_type
except ImportError:
- from OFS.content_types import guess_content_type
+ try:
+ # >= Zope 2.10
+ from zope.app.content_types import guess_content_type
+ except ImportError:
+ # < Zope 2.10 (I think)
+ from OFS.content_types import guess_content_type
FILESTREAM_ITERATOR_THRESHOLD = 2 << 16 # 128 Kb (from LocalFS StreamingFile.py)
View
2 IssueTrackerProduct/zpt/OptionButtons.zpt
@@ -8,6 +8,6 @@
onkeypress string:softsubmit('${button/action}');;return false;;;
id python:test(button.get('id'), button.get('id'))"
- tal:content="structure python:button['verb'].replace(' ','&nbsp;')"></a>&nbsp;</li>
+ tal:content="structure python:button['verb']"></a>&nbsp;</li>
</ul>
<br style="clear:both" />
View
2 IssueTrackerProduct/zpt/StandardHeader.zpt
@@ -45,7 +45,7 @@ ul#tabnav a {
<body>
<div id="head">
- <h1 class="head" tal:content="structure python:here.getRoot().title_or_id().replace(' ','&nbsp;')">The Title</h1>
+ <h1 class="head" tal:content="structure python:here.getRoot().title_or_id()">The Title</h1>
<div id="topright">
<form metal:use-macro="here/search_widget/macros/search_form"></form>

0 comments on commit 557c628

Please sign in to comment.