"""google appengine configuration:organization: Logilab:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses"""__docformat__="restructuredtext en"importosfromos.pathimportjoinfromcubicwebimportCW_SOFTWARE_ROOTfromcubicweb.cwconfigimportCubicWebConfigurationfromcubicweb.web.webconfigimportWebConfiguration,merge_optionsfromcubicweb.server.serverconfigimportServerConfigurationfromcubicweb.goa.dbmyamsimportload_schemaUNSUPPORTED_OPTIONS=set(('connections-pool-size','pyro-port','pyro-id','pyro-application-id','pyro-ns-host','pyro-ns-port','pyro-ns-group','https-url','host','pid-file','uid','base-url','log-file','smtp-host','smtp-port','embed-allowed',))# XXX fix:# * default sender-name / sender-addr value# * what about *session-time# * check auth-mode=http + fix doc (eg require use-google-auth = False)classGAEConfiguration(ServerConfiguration,WebConfiguration):"""repository and web application in the same twisted process"""name='app'repo_method='inmemory'options=merge_options((('included-cubes',{'type':'csv','default':[],'help':'list of db model based cubes used by the application.','group':'main','inputlevel':1,}),('included-yams-cubes',{'type':'csv','default':[],'help':'list of yams based cubes used by the application.','group':'main','inputlevel':1,}),('use-google-auth',{'type':'yn','default':True,'help':'does this application rely on google authentication service or not.','group':'main','inputlevel':1,}),('schema-type',{'type':'choice','choices':('yams','dbmodel'),'default':'yams','help':'does this application is defining its schema using yams or db model.','group':'main','inputlevel':1,}),# overriden options('query-log-file',{'type':'string','default':None,'help':'web application query log file: DON\'T SET A VALUE HERE WHEN ''UPLOADING YOUR APPLICATION. This should only be used to analyse ''queries issued by your application in the development environment.','group':'main','inputlevel':2,}),('anonymous-user',{'type':'string','default':None,'help':'login of the CubicWeb user account to use for anonymous user ''(if you want to allow anonymous). This option will be ignored if ''use-google-auth option is set (in which case you should control ''anonymous access using the app.yaml file)','group':'main','inputlevel':1,}),)+WebConfiguration.options+ServerConfiguration.options)options=[(optname,optdict)foroptname,optdictinoptionsifnotoptnameinUNSUPPORTED_OPTIONS]cubicweb_vobject_path=WebConfiguration.cubicweb_vobject_path|ServerConfiguration.cubicweb_vobject_pathcubicweb_vobject_path=list(cubicweb_vobject_path)+['goa/appobjects']cube_vobject_path=WebConfiguration.cube_vobject_path|ServerConfiguration.cube_vobject_path# use file system schemabootstrap_schema=read_application_schema=False# schema is not persistent, don't load schema hooks (unavailable)schema_hooks=False# no user workflow for nowconsider_user_state=False# deactivate some hooks during [pre|post]create scripts execution# (unique values check, owned_by/created_by relations setup)free_wheel=Trueifnotos.environ.get('APYCOT_ROOT'):CUBES_DIR=join(CW_SOFTWARE_ROOT,'../cubes')def__init__(self,appid,apphome=None):ifapphomeisNone:apphome='data'self._apphome=apphomeself._base_url=NoneCubicWebConfiguration.__init__(self,appid)def__getitem__(self,key):ifkey=='connections-pool-size':return4# > 1 to allow multiple user sessions in testsifkey=='base-url':returnself._base_urlreturnsuper(GAEConfiguration,self).__getitem__(key)# overriden from cubicweb base configuration@propertydefapphome(self):returnself._apphomedefcubes(self):"""return the list of top level cubes used by this instance (eg without dependencies) """ifself._cubesisNone:cubes=self['included-cubes']+self['included-yams-cubes']cubes=self.expand_cubes(cubes)returnself.reorder_cubes(cubes)returnself._cubesdefvc_config(self):"""return CubicWeb's engine and application's cube versions number"""return{}# overriden from cubicweb web configurationdefinstance_md5_version(self):return''def_init_base_url(self):pass# overriden from cubicweb server configurationdefsources(self):return{'system':{'adapter':'gae'}}defload_schema(self,schemaclasses=None,extrahook=None):try:returnself._schemaexceptAttributeError:self._schema=load_schema(self,schemaclasses,extrahook)returnself._schema# goa specificdefrepo_session(self,sessionid):returnself.repository()._sessions[sessionid]defis_anonymous_user(self,login):ifself['use-google-auth']:fromgoogle.appengine.apiimportusersreturnusers.get_current_user()isNoneelse:returnlogin==self.anonymous_user()[0]