Author: whit Date: 2007-11-13 15:30:17 -0500 (Tue, 13 Nov 2007) New Revision: 10962
Added: sputnik/trunk/sputnik/zinit.py Removed: sputnik/trunk/sputnik/delete-project.txt sputnik/trunk/sputnik/tests.py Modified: sputnik/trunk/sputnik/configure.zcml Log: - remove delete-project tests - move zope package initialization to own module (making sputnik sane as a nonzope library) Modified: sputnik/trunk/sputnik/configure.zcml =================================================================== --- sputnik/trunk/sputnik/configure.zcml 2007-11-13 20:26:18 UTC (rev 10961) +++ sputnik/trunk/sputnik/configure.zcml 2007-11-13 20:30:17 UTC (rev 10962) @@ -4,7 +4,8 @@ xmlns:i18n="http://namespaces.zope.org/i18n" > - <five:registerPackage package="." initialize=".initialize" /> + <five:registerPackage package="sputnik" + initialize="sputnik.zinit.initialize" /> <browser:view for="*" Deleted: sputnik/trunk/sputnik/delete-project.txt =================================================================== --- sputnik/trunk/sputnik/delete-project.txt 2007-11-13 20:26:18 UTC (rev 10961) +++ sputnik/trunk/sputnik/delete-project.txt 2007-11-13 20:30:17 UTC (rev 10962) @@ -1,133 +0,0 @@ -=================== - Project deletions -=================== - -Project deletion cascades a number of other events: external and -internal app deletion and the removal of the corresponding team and -all the memberships. - -First, let's test our deletion handlers directly:: - - >>> project = self.projects.p1 - -Let's add some featurelets:: - - >>> self.loginAsPortalOwner() #@@ this should be the project owner - - >>> IFeatureletSupporter(project).installFeaturelet(TaskTrackerFeaturelet()) # the ... shouldn't be necessary, test conf overrides ought to set this to http://nohost:tasktracker (so this is a real bug) -egj - Called httplib2.Http.request( - u'http://.../project/initialize/', - headers={'X-Openplans-Project': 'p1', 'X-Openplans-Tasktracker-Initialize': 'True', 'Cookie': '__ac=...'}, - method='POST') - - >>> IFeatureletSupporter(project).installFeaturelet(ListenFeaturelet()) - -Flet Removal -============ - - >>> from opencore.nui.project.preferences import handle_flet_uninstall - - << POST? shouldn't it be DELETE? egj? -- you think tasktracker is - remotely restful? :P actually, tho, it shouldn't be DELETE, because - it just flips a switch rather than really deleting any content. this - might not be what project deletion wants, but it suffices to make - the content unaccessible (until the next time that project's TT is - installed) (hmm, this will be a problem if a new project is allowed - to be created with the same name as the deleted one .. is that the - case?) -egj >> - - >>> handle_flet_uninstall(project) - Called httplib2.Http.request( - u'http://.../project/uninitialize/', - headers={'X-Openplans-Project': 'p1', 'Cookie': '__ac=...'}, - method='POST') - -Gotta reinstall:: - - >>> IFeatureletSupporter(project).installFeaturelet(TaskTrackerFeaturelet()) - Called... - - -Team removal -============ - - >>> from opencore.nui.project.preferences import delete_team - -We'll kill a team we don't need for this test:: - - >>> delete_team(self.portal, self.request, [self.projects.p4.getId()]) - >>> sorted(self.portal.portal_teams.objectIds()) - ['.wf_policy_config', 'p1', 'p2', 'p3'] - -Here's our chicken (ClockQueue should see the second delete we do as -the same job):: - - >>> pprint(sorted([x for x in IClockQueue(self.projects)])) - [(..., - <topp.clockqueue.Job 'opencore.nui.project.preferences.delete_team' args:() kw:{'ids': ['p4']}>)] - -Since this is a bad situation, we make repeated deletes -'safe'. 'delete_teams' prints and logs the formatted exception:: - - >>> print delete_team(self.portal, self.request, ['p4']) - Traceback...BadRequest: p4 does not exist... - -Just one safe chicken...not more:: - - >>> pprint(sorted([x for x in IClockQueue(self.projects)])) - [(..., - <topp.clockqueue.Job 'opencore.nui.project.preferences.delete_team' args:() kw:{'ids': ['p4']}>)] - -Put it all together -=================== - - >>> project.getTeams() - [<OpenTeam at /plone/portal_teams/p1>] - - >>> view = project.restrictedTraverse('preferences') - >>> view - <...project/preferences-w-delete.pt...> - - <...sputnik/preferences.pt...> - - >>> deleting = view._handle_delete() - Called httplib2.Http.request( - u'http://.../project/uninitialize/', - headers={'X-Openplans-Project': 'p1', 'Cookie': '__ac=...'}, - method='POST') - - >>> deleting - True - -Free up the references:: - - >>> del project - >>> del view - -p1 should be gone:: - - >>> sorted(self.projects.objectIds()) - ['.wf_policy_config', 'p2', 'p3', 'p4'] - -The team should be queued for deletion:: - - >>> pprint(sorted([x for x in IClockQueue(self.projects)])) - [(..., - <topp.clockqueue.Job 'opencore.nui.project.preferences.delete_team' args:() kw:{'ids': ['p1']}>), - (..., - <topp.clockqueue.Job 'opencore.nui.project.preferences.delete_team' args:() kw:{'ids': ['p4']}>)] - -We should redirect to somewhere sensible... `start a project`? - - >>> print self.request.RESPONSE.headers['location'] - http://nohost/plone/projects/create - -What else? - - - - - - - - Deleted: sputnik/trunk/sputnik/tests.py =================================================================== --- sputnik/trunk/sputnik/tests.py 2007-11-13 20:26:18 UTC (rev 10961) +++ sputnik/trunk/sputnik/tests.py 2007-11-13 20:30:17 UTC (rev 10962) @@ -1,63 +0,0 @@ -import os, sys, unittest -from zope.testing import doctest -from Testing import ZopeTestCase -from Testing.ZopeTestCase import PortalTestCase -from Testing.ZopeTestCase import FunctionalDocFileSuite -from opencore.testing.layer import OpencoreContent as test_layer -from Products.OpenPlans.tests.openplanstestcase import OpenPlansTestCase -from opencore.testing.layer import MockHTTPWithContent, OpenPlansLayer -from opencore.tasktracker.tests import readme_setup -from opencore.testing import * - - -#optionflags = doctest.REPORT_ONLY_FIRST_FAILURE | doctest.ELLIPSIS -optionflags = doctest.ELLIPSIS - -import warnings; warnings.filterwarnings("ignore") - -def hello_world(context, howdy=False): - return "Hello world: %s howdy=%s" %(context, howdy) - -def test_suite(): - import pdb - from Products.PloneTestCase import setup - from Products.PloneTestCase.PloneTestCase import FunctionalTestCase - from Testing.ZopeTestCase import FunctionalDocFileSuite, installProduct - - # @@ bah... crappy irregular import scheme - from opencore.tasktracker.featurelet import TaskTrackerFeaturelet - from opencore.featurelets.listen import ListenFeaturelet - - from opencore.testing import noLongerProvides - from opencore.utility.interfaces import IHTTPClient - from pprint import pprint - from zope.component import getMultiAdapter, getUtility - from zope.interface import alsoProvides - from topp.featurelets.interfaces import IFeatureletSupporter - from topp.clockqueue.interfaces import IClockQueue - - setup.setupPloneSite() - def base_setup(tc): - readme_setup(tc) - tc._refreshSkinData() - tc.request = tc.app.REQUEST - tc.response = tc.request.RESPONSE - tc.homepage = getattr(tc.portal, 'site-home') - tc.projects = tc.portal.projects - - globs = locals() - delete = FunctionalDocFileSuite("delete-project.txt", - optionflags=optionflags, - package='sputnik', - test_class=OpenPlansTestCase, - globs = globs, - setUp=base_setup - ) - - delete.layer = MockHTTPWithContent - - return unittest.TestSuite((delete,)) - - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') Added: sputnik/trunk/sputnik/zinit.py =================================================================== --- sputnik/trunk/sputnik/zinit.py (rev 0) +++ sputnik/trunk/sputnik/zinit.py 2007-11-13 20:30:17 UTC (rev 10962) @@ -0,0 +1,30 @@ +from Products.PageTemplates.GlobalTranslationService import \ + setGlobalTranslationService +from Products.PlacelessTranslationService.PlacelessTranslationService \ + import PTSWrapper +from Products.PlacelessTranslationService.PlacelessTranslationService \ + import catalogRegistry + +def initialize(context): + """ + Initialization function that bootstraps us as a Zope product. + We're forcing our .po files into the PTS catalog registry, and + making sure they're _before_ the OpenPlans ones, so our + translations will win. + """ + cp = context._ProductContext__app.Control_Panel + cp_ts = cp.TranslationService + cp_ts._load_i18n_dir("%s/i18n" % __path__[0]) + + # it seems to always be first, but we force it here just in case + oc_keys = [key for key in catalogRegistry.keys() if key[1] == 'opencore'] + for key in oc_keys: + new_order = [] # <-- must be Blue Monday again + cats = catalogRegistry.get(key) + for cat in cats: + if cat.startswith('sputnik'): + new_order.insert(0, cat) + else: + new_order.append(cat) + catalogRegistry[key] = new_order + cp_ts._p_changed = True -- Archive: http://www.openplans.org/projects/opencore/lists/openplans-svn/archive/2007/11/1194985818433 To unsubscribe send an email with subject unsubscribe to [EMAIL PROTECTED] Please contact [EMAIL PROTECTED] for questions.