osdir.com
mailing list archive F.A.Q. -since 2001!



Subject: testing Five-ish products - msg#00055

List: web.zope.z3base.five

Mail Archive Navigation:
by Date: Prev Next Date Index by Thread: Prev Next Thread Index

Hi all,

What's the "correct" way to do functional tests for a Five-ish product,
I'm trying to do the following:

(apologies for the length, gotta love the amount of kicking Zope 2 needs ;-)

import Globals
import logging
import transaction
import Zope2

from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
# this import, rather evilly, causes Zope2.bobo_application and Zope2.DB
# to come into existence :-(
from Testing.ZopeTestCase import ZopeLite
from Testing.ZopeTestCase.utils import makerequest
from ZODB import DB
from ZODB.DemoStorage import DemoStorage

state = [Zope2.DB]

def setChickens(db):
# Zope 2 chickens
Globals.BobobaseName = db.getName()
Globals.DB = db
Zope2.DB = db
Globals.UndoManager=db
ZopeLite.DB = db
junk_db, name, version_support = Zope2.bobo_application._stuff
Zope2.bobo_application._stuff = db, name, version_support

def addDB():
global state
previous = state[-1]
storage = DemoStorage(base=previous._storage)
db = DB(storage)
# cluck
db.classFactory = previous.classFactory
# cluck cluck
setChickens(db)
state.append(db)


def removeDB():
global state
db = state.pop()
db.close()
# un-cluck
setChickens(state[-1])

def Zope2SetUp(test):
global state
previous = state[-1]
storage = DemoStorage(base=previous._storage)
db = DB(storage)
# cluck
db.classFactory = previous.classFactory
# cluck cluck
setChickens(db)
state.append(db)
# install product
ZopeLite.installProduct('Five')
ZopeLite.installProduct('twiddler.zope2')

def Zope2TearDown(test):
global state
db = state.pop()
db.close()
# un-cluck
setChickens(state[-1])

def setUp(test):
Zope2SetUp(test)
a = app()
a.manage_addFolder('folder')
test.globs['folder']=a.folder

def test_suite():
return unittest.TestSuite((
DocFileSuite('../readme.txt', optionflags=options,
setUp=setUp,
tearDown=Zope2TearDown),
))

I get the following error:

File "C:\Zope\2.9.4\lib\python\zope\configuration\config.py", line 612,
in execute_actions
callable(*args, **kw)
File "Products\pythonproducts\pythonproducts.py", line 57, in
_registerPackage
_zope_app)
File "C:\Zope\2.9.4\lib\python\App\Product.py", line 497, in
initializeProduct

products=app.Control_Panel.Products
ConfigurationExecutionError: exceptions.AttributeError: 'NoneType'
object has no
attribute 'Control_Panel'
in:
File "lib\python\twiddler\zope2\configure.zcml", line 6.0-6.61
<five:registerPackage package="." initialize=".initialize" />

If I remove the installProduct('Five'), I get the following instead:

File "<doctest readme.txt[0]>", line 1, in ?
folder.manage_addProduct['twiddler.zope2'].addTwiddler('test')
File "C:\Zope\2.9.4\lib\python\App\FactoryDispatcher.py", line 26, in
__getitem__
return self.__bobo_traverse__(None, name)
File "C:\Zope\2.9.4\lib\python\App\FactoryDispatcher.py", line 29, in
__bobo_traverse__
product=self.aq_acquire('_getProducts')()._product(name)
File "C:\Zope\2.9.4\lib\python\App\Product.py", line 69, in _product
def _product(self, name): return getattr(self, name)
AttributeError: twiddler.zope2

Any help greatfully received...

Chris

--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk


Thread at a glance:

Previous Message by Date:

Re: weird security problem with Five.browser.BrowserView

Chris Withers schrieb: > Hi All, > Hi Chris, [..] > from Products.Five.browser import BrowserView > > class Contents(BrowserView): > > highlight_tab = '@@contents' > Wild guess: what if you give this class a doc-string? Raphael

Next Message by Date:

Re: weird security problem with Five.browser.BrowserView

Raphael Ritz wrote: >> class Contents(BrowserView): >> >> highlight_tab = '@@contents' >> > Wild guess: what if you give this class a doc-string? Doesn't make a difference... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk

Previous Message by Thread:

weird security problem with Five.browser.BrowserView

Hi All, Got a strange security problem for a view registered as follows: <browser:page for="SomeInteface" name="contents" class=".views.contents.Contents" template="views/content.pt" permission="Zope2.View"/> The view class is: from Products.Five.browser import BrowserView class Contents(BrowserView): highlight_tab = '@@contents' content.pt is: <html metal:use-macro="here/main_template/macros/master"> ... <tal:x metal:fill-slot="body" replace="view/highlight_tab"> </html> main_template.pt is an FS ZPT in a skins folder: <html metal:define-macro="master"> <taldisabled:x content="view/highlight_tab"/> <tal:x metal:define-slot="body"/> </html> Now, all works well, except that if I enable the view/highlight_tab statement in main_template.pt, I get an Unauthorized error on 'highlight_tab'. If checked that everything appears to be acquisition wrapped as it should. I've even tried changing the view registration to: <browser:page for="SomeInteface" name="contents" class=".views.contents.Contents" allowed_attributes="highlight_tab" template="views/content.pt" permission="Zope2.View"/> ...and the view class to: class Contents(BrowserView): security = ClassSecurityInfo() security.declareObjectPublic() security.setDefaultAccess('allow') highlight_tab='@@contents' ...all to no avail. It seems the security machinery is trying to establing the acquisition contents of '@@contents', which of course has no aq context 'cos it's only a simple string. The only think I have found which does work is changing the view class definition to: class Contents(BrowserView): def highlight_tab(self): 'cluck cluck' return '@@contents' ...but that seems a bit nasty. I haven't had this kind of problem with "normal" Zope 2 classes, so I'm wondering what's going on here to cause these problems? any ideas? Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk

Next Message by Thread:

Azax Error looking for directive

I am getting this error when installing Azax on Plone 2.5.1, Zope 2.9.5, Five 1.4.2. What do I have to do to register the new directive? ZopeXMLConfigurationError: File "C:\PLONE\Data\Products\PloneAzax\configure.zcml", line 10.4-10.33 ZopeXMLConfigurationError: File "C:\PLONE\Data\Products\PloneAzax\plugins\configure.zcml", line 11.2-11.31 ZopeXMLConfigurationError: File "C:\PLONE\Data\Products\PloneAzax\plugins\legacy\configure.zcml", line 9.4 ConfigurationError: ('Unknown directive', u'http://namespaces.zope.org/azax', u'registerAction') <configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" xmlns:azax="http://namespaces.zope.org/azax" > <!-- reload plugin for content menus --> <azax:registerAction name="bindActionMenus" jsfile="reload/bindmenus.js" /> <azax:registerAction name="initializeCollapsible" jsfile="reload/initializeCollapsible.js" /> </configure>
blog comments powered by Disqus

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz is too!