[uiprops] use lazystr and update some variables usage in css
to get a chance to change style without having to change all properties.
Also had missing boxHeader.png file (formerly header.png).
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr## This file is part of CubicWeb.## CubicWeb is free software: you can redistribute it and/or modify it under the# terms of the GNU Lesser General Public License as published by the Free# Software Foundation, either version 2.1 of the License, or (at your option)# any later version.## CubicWeb is distributed in the hope that it will be useful, but WITHOUT# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more# details.## You should have received a copy of the GNU Lesser General Public License along# with CubicWeb. If not, see <http://www.gnu.org/licenses/>."""provide utilies for web (live) unit testing"""importosimportsocketimportloggingfromos.pathimportjoin,dirname,normpath,abspathfromStringIOimportStringIO#from twisted.application import service, strports# from twisted.internet import reactor, taskfromtwisted.web2importchannelfromtwisted.web2importserverfromtwisted.web2importstaticfromtwisted.internetimportreactorfromtwisted.internet.errorimportCannotListenErrorfromlogilab.common.testlibimportTestCasefromcubicweb.dbapiimportin_memory_cnxfromcubicweb.etwist.serverimportCubicWebRootResourcefromcubicweb.devtoolsimportBaseApptestConfiguration,init_test_databasedefget_starturl(port=7777,login=None,passwd=None):iflogin:return'http://%s:%s/view?login=%s&password=%s'%(socket.gethostname(),port,login,passwd)else:return'http://%s:%s/'%(socket.gethostname(),port)classLivetestResource(CubicWebRootResource):"""redefines main resource to search for data files in several directories"""deflocateChild(self,request,segments):"""Indicate which resource to use to process down the URL's path"""iflen(segments)andsegments[0]=='data':# Anything in data/ is treated as static filesdatadir=self.config.locate_resource(segments[1])[0]ifdatadir:returnstatic.File(str(datadir),segments[1:])# Otherwise we use this single resourcereturnself,()classLivetestConfiguration(BaseApptestConfiguration):init_repository=Falsedef__init__(self,cube=None,sourcefile=None,pyro_name=None,log_threshold=logging.CRITICAL):BaseApptestConfiguration.__init__(self,cube,log_threshold=log_threshold)self.appid=pyro_nameorcube# don't change this, else some symlink problems may arise in some# environment (e.g. mine (syt) ;o)# XXX I'm afraid this test will prevent to run test from a production# environmentself._sources=None# instance cube testifcubeisnotNone:self.apphome=self.cube_dir(cube)elif'web'inos.getcwd().split(os.sep):# web testself.apphome=join(normpath(join(dirname(__file__),'..')),'web')else:# cube testself.apphome=abspath('..')self.sourcefile=sourcefileself.global_set_option('realm','')self.use_pyro=pyro_nameisnotNonedefpyro_enabled(self):ifself.use_pyro:returnTrueelse:returnFalsedefmake_site(cube,options=None):fromcubicweb.etwistimporttwconfig# trigger configuration registrationconfig=LivetestConfiguration(cube,options.sourcefile,pyro_name=options.pyro_name,log_threshold=logging.DEBUG)init_test_database(config=config)# if '-n' in sys.argv: # debug modecubicweb=LivetestResource(config,debug=True)toplevel=cubicwebwebsite=server.Site(toplevel)cube_dir=config.cube_dir(cube)source=config.sources()['system']forportinxrange(7777,7798):try:reactor.listenTCP(port,channel.HTTPFactory(website))saveconf(cube_dir,port,source['db-user'],source['db-password'])breakexceptCannotListenError:print"port %s already in use, I will try another one"%portelse:raisecubicweb.base_url=get_starturl(port=port)print"you can go here : %s"%cubicweb.base_urldefrunserver():reactor.run()defsaveconf(templhome,port,user,passwd):importpickleconffile=file(join(templhome,'test','livetest.conf'),'w')pickle.dump((port,user,passwd,get_starturl(port,user,passwd)),conffile)conffile.close()defloadconf(filename='livetest.conf'):importpicklereturnpickle.load(file(filename))defexecute_scenario(filename,**kwargs):"""based on twill.parse.execute_file, but inserts cubicweb extensions"""fromtwill.parseimport_execute_scriptstream=StringIO('extend_with cubicweb.devtools.cubicwebtwill\n'+file(filename).read())kwargs['source']=filename_execute_script(stream,**kwargs)defhijack_twill_output(new_output):fromtwillimportcommandsastwcfromtwillimportbrowserastwbtwc.OUT=new_outputtwb.OUT=new_outputclassLiveTestCase(TestCase):sourcefile=Nonecube=''defsetUp(self):assertself.cube,"You must specify a cube in your testcase"# twill can be quite verbose ...self.twill_output=StringIO()hijack_twill_output(self.twill_output)# build a config, and get a connectionself.config=LivetestConfiguration(self.cube,self.sourcefile)_,user,passwd,_=loadconf()self.repo,self.cnx=in_memory_cnx(self.config,user,password=passwd)self.setup_db(self.cnx)deftearDown(self):self.teardown_db(self.cnx)defsetup_db(self,cnx):"""override setup_db() to setup your environment"""defteardown_db(self,cnx):"""override teardown_db() to clean up your environment"""defget_loggedurl(self):port,user,passwd,logged_url=loadconf()returnlogged_urldefget_anonurl(self):port,_,_,_=loadconf()return'http://%s:%s/view?login=anon&password=anon'%(socket.gethostname(),port)# convenienceexecute_scenario=staticmethod(execute_scenario)if__name__=='__main__':runserver()