[schema] neuter check method for constraints we implement in sql
Closes #5154406.
# copyright 2003-2011 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/>."""WSGI request adapter for cubicwebNOTE: each docstring tagged with ``COME FROM DJANGO`` means thatthe code has been taken (or adapted) from Djanco source code : http://www.djangoproject.com/"""__docformat__="restructuredtext en"importtempfilefromStringIOimportStringIOfromurllibimportquotefromurlparseimportparse_qsfromwarningsimportwarnfromcubicweb.multipartimport(copy_file,parse_form_data,MultipartError,parse_options_header)fromcubicweb.webimportRequestErrorfromcubicweb.web.requestimportCubicWebRequestBasefromcubicweb.wsgiimportpformat,normalize_headerclassCubicWebWsgiRequest(CubicWebRequestBase):"""most of this code COMES FROM DJANGO """def__init__(self,environ,vreg):# self.vreg is used in get_posted_data, which is called before the# parent constructor.self.vreg=vregself.environ=environself.path=environ['PATH_INFO']self.method=environ['REQUEST_METHOD'].upper()# content_length "may be empty or absent"try:length=int(environ['CONTENT_LENGTH'])except(KeyError,ValueError):length=0# wsgi.input is not seekable, so copy the request contents to a temporary fileiflength<100000:self.content=StringIO()else:self.content=tempfile.TemporaryFile()copy_file(environ['wsgi.input'],self.content,maxread=length)self.content.seek(0,0)environ['wsgi.input']=self.contentheaders_in=dict((normalize_header(k[5:]),v)fork,vinself.environ.items()ifk.startswith('HTTP_'))if'CONTENT_TYPE'inenviron:headers_in['Content-Type']=environ['CONTENT_TYPE']https=self.is_secure()ifself.path.startswith('/https/'):self.path=self.path[6:]self.environ['PATH_INFO']=self.pathhttps=Truepost,files=self.get_posted_data()super(CubicWebWsgiRequest,self).__init__(vreg,https,post,headers=headers_in)self.content=environ['wsgi.input']iffilesisnotNone:forkey,partinfiles.iteritems():self.form[key]=(part.filename,part.file)def__repr__(self):# Since this is called as part of error handling, we need to be very# robust against potentially malformed input.form=pformat(self.form)meta=pformat(self.environ)return'<CubicWebWsgiRequest\FORM:%s,\nMETA:%s>'% \(form,meta)## cubicweb request interface ################################################defhttp_method(self):"""returns 'POST', 'GET', 'HEAD', etc."""returnself.methoddefrelative_path(self,includeparams=True):"""return the normalized path of the request (ie at least relative to the instance's root, but some other normalization may be needed so that the returned path may be used to compare to generated urls :param includeparams: boolean indicating if GET form parameters should be kept in the path """path=self.environ['PATH_INFO']path=path[1:]# remove leading '/'ifincludeparams:qs=self.environ.get('QUERY_STRING')ifqs:return'%s?%s'%(path,qs)returnpath## wsgi request helpers ###################################################defis_secure(self):returnself.environ['wsgi.url_scheme']=='https'defget_posted_data(self):# The WSGI spec says 'QUERY_STRING' may be absent.post=parse_qs(self.environ.get('QUERY_STRING',''))files=Noneifself.method=='POST':content_type=self.environ.get('CONTENT_TYPE')ifnotcontent_type:raiseRequestError("Missing Content-Type")content_type,options=parse_options_header(content_type)ifcontent_typein('multipart/form-data','application/x-www-form-urlencoded','application/x-url-encoded'):forms,files=parse_form_data(self.environ,strict=True,mem_limit=self.vreg.config['max-post-length'])post.update(forms.dict)self.content.seek(0,0)returnpost,filesdefsetup_params(self,params):# This is a copy of CubicWebRequestBase.setup_params, but without# converting unicode strings because it is partially done by# get_posted_dataself.form={}ifparamsisNone:returnencoding=self.encodingforparam,valinparams.iteritems():ifisinstance(val,(tuple,list)):val=[unicode(x,encoding)ifisinstance(x,str)elsexforxinval]iflen(val)==1:val=val[0]elifisinstance(val,str):val=unicode(val,encoding)ifparaminself.no_script_form_paramsandval:val=self.no_script_form_param(param,val)ifparam=='_cwmsgid':self.set_message_id(val)else:self.form[param]=val