当前位置: 首页>>代码示例>>Python>>正文


Python zoo._函数代码示例

本文整理汇总了Python中zoo._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetGroupsUser

def GetGroupsUser(conf,inputs,outputs):
	if is_connected(conf):
		c = auth.getCon(conf)
		if not c.connect():
			conf["lenv"]["message"] = zoo._("SQL connection error")
			return 4
		if not re.match(r"(^\d+$)|(NULL)",inputs["id"]["value"]):
			conf["lenv"]["message"] = zoo._("Parameter id invalid")
			return 4
		if not re.match(r"(^\w+\Z)",inputs["order"]["value"]):
                        conf["lenv"]["message"] = zoo._("Parametre order incorrect")
                        return 4
		if not re.match(r"(desc)|(asc)",inputs["sort"]["value"]):
                        conf["lenv"]["message"] = zoo._("Parameter sort invalid")
                        return 4	
		if c.is_admin(conf["senv"]["login"]):
			if inputs["id"]["value"] == "NULL":
				outputs["Result"]["value"] = json.dumps(c.get_groups_user_by_login(conf["senv"]["login"],inputs["order"]["value"],inputs["sort"]["value"]))
			else:
				outputs["Result"]["value"] = json.dumps(c.get_groups_user_by_id(int(inputs["id"]["value"]),inputs["order"]["value"],inputs["sort"]["value"]))
		else:
			outputs["Result"]["value"] = json.dumps(c.get_groups_user_by_login(conf["senv"]["login"],inputs["order"]["value"],inputs["sort"]["value"]))
		return 3

	else:
		conf["lenv"]["message"]=zoo._("User not authenticated")
		return 4
开发者ID:ThomasG77,项目名称:mapmint,代码行数:27,代码来源:service_users.py

示例2: test

def test(conf, inputs, outputs):
    libxml2.initParser()
    xcontent = (
        "<connection><dbname>"
        + inputs["dbname"]["value"]
        + "</dbname><user>"
        + inputs["user"]["value"]
        + "</user><password>"
        + inputs["password"]["value"]
        + "</password><host>"
        + inputs["host"]["value"]
        + "</host><port>"
        + inputs["port"]["value"]
        + "</port></connection>"
    )
    doc = libxml2.parseMemory(xcontent, len(xcontent))
    styledoc = libxml2.parseFile(conf["main"]["dataPath"] + "/" + inputs["type"]["value"] + "/conn.xsl")
    # print >> sys.stderr,conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/conn.xsl"
    style = libxslt.parseStylesheetDoc(styledoc)
    result = style.applyStylesheet(doc, None)
    # print >> sys.stderr,"("+result.content+")"
    ds = osgeo.ogr.Open(result.content)
    if ds is None:
        conf["lenv"]["message"] = zoo._("Unable to connect to ") + inputs["name"]["value"]
        return 4
    else:
        outputs["Result"]["value"] = zoo._("Connection to ") + inputs["name"]["value"] + zoo._(" successfull")
    ds = None
    return 3
开发者ID:nbozon,项目名称:mapmint,代码行数:29,代码来源:service.py

示例3: AddUser

def AddUser(conf,inputs,outputs):
	if is_connected(conf):
		c = auth.getCon(conf)
		prefix=auth.getPrefix(conf)
		if c.is_admin(conf["senv"]["login"]):
			try:
				user = json.loads(inputs["user"]["value"])
                	except Exception,e:
				print >> sys.stderr,inputs["user"]["value"]
                        	print >> sys.stderr,e
                        	conf["lenv"]["message"] = zoo._("invalid user parameter: ")+inputs["user"]["value"]
                        	return 4
			for (i,j) in user.items():
				if not manage_users.check_user_params(i,j):
					conf["lenv"]["message"] = 'Parametre %s incorrect'%(i)
					return 4
			if c.add_user(user):
				outputs["Result"]["value"] = inputs["user"]["value"]
				if inputs.has_key("group"):
					if inputs["group"].has_key("length"):
						for i in range(0,len(inputs["group"]["value"])):
							linkGroupToUser(c,prefix,inputs["group"]["value"],inputs["login"]["value"])
					else:
						linkGroupToUser(c,prefix,inputs["group"]["value"],user["login"])
				return 3
			else:
				conf["lenv"]["message"] = zoo._("SQL Error")
				return 4
		else:
			conf["lenv"]["message"]= zoo._("Action not permited")
			return 4
开发者ID:ThomasG77,项目名称:mapmint,代码行数:31,代码来源:service_users.py

示例4: SecureAccess

def SecureAccess(conf,inputs,outputs):
    global myCookies
    mapfile=conf["main"]["dataPath"]+"/public_maps/project_"+inputs["server"]["value"]+".map"
    try:
    	myMap=mapscript.mapObj(mapfile)
    except:
        conf["lenv"]["message"]=zoo._("Unable to find any project with this name!")
	return zoo.SERVICE_FAILED
    c = auth.getCon(conf)
    prefix=auth.getPrefix(conf)
    if not(validToken(c,prefix,inputs["token"]["value"])):
        conf["lenv"]["message"]=zoo._("Unable to validate your token!")
        return zoo.SERVICE_FAILED
    if not(validIp(conf,c,prefix,inputs["ip"]["value"],0,[inputs["server"]["value"]])):
        conf["lenv"]["message"]=zoo._("You are not allowed to access the ressource using this ip address!")
        return zoo.SERVICE_FAILED
    q=None
    if inputs["Query"]["mimeType"]=="application/json":
        import json
        q=json.loads(inputs["Query"]["value"])
    myAutorizedGroups=myMap.web.metadata.get('mm_access_groups').split(',')
    if myAutorizedGroups.count('public')==0 and not(q is None or q["request"].upper()=="GETCAPABILITIES" or q["request"].upper()=="GETLEGENDGRAPHIC") and not(tryIdentifyUser(conf,inputs["user"]["value"],inputs["password"]["value"])):
        conf["lenv"]["message"]=zoo._("You are not allowed to access the ressource using this user / password!")
        conf["lenv"]["status_code"]="401 Unauthorized"
        print >> sys.stderr,conf["lenv"]
        return zoo.SERVICE_FAILED
    if conf.keys().count("senv")==0:
        conf["senv"]={"group": getGroupFromToken(c,prefix,inputs["token"]["value"])}
    else:
        print >> sys.stderr,conf["senv"]
    try:
    	myCurrentGroups=conf["senv"]["group"].split(',')
    except Exception,e:
    	myCurrentGroups=[]
开发者ID:mapmint,项目名称:mapmint,代码行数:34,代码来源:service.py

示例5: addColumn

def addColumn(conf,inputs,outputs):
    print >> sys.stderr,inputs["dataStore"]["value"]
    db=pgConnection(conf,inputs["dataStore"]["value"])
    db.parseConf()
    req=[]
    if db.connect():
        if inputs["field_type"]["value"]!="18":
            req+=["ALTER TABLE quote_ident("+inputs["table"]["value"]+") ADD COLUMN "+inputs["field_name"]["value"]+" "+fetchType(conf,inputs["field_type"]["value"])]
            outputs["Result"]["value"]=zoo._("Column added")
        else:
            tblInfo=inputs["table"]["value"].split(".")
            if len(tblInfo)==1:
                tmp=tblInfo[0]
                tblInfo[0]="public"
                tblInfo[1]=tmpl
            req+=["SELECT AddGeometryColumn('"+tblInfo[0]+"','"+tblInfo[1]+"','wkb_geometry',(select srid from spatial_ref_sys where auth_name||':'||auth_srid = '"+inputs["proj"]["value"]+"'),'"+inputs["geo_type"]["value"]+"',2)"]
            outputs["Result"]["value"]=zoo._("Geometry column added.")
            if inputs.keys().count("geo_x")>0 and inputs.keys().count("geo_y")>0:
                req+=["CREATE TRIGGER mm_tables_"+inputs["table"]["value"].replace(".","_")+"_update_geom BEFORE UPDATE OR INSERT ON "+inputs["table"]["value"]+" FOR EACH ROW EXECUTE PROCEDURE automatically_update_geom_property('"+inputs["geo_x"]["value"]+"','"+inputs["geo_y"]["value"]+"','"+inputs["proj"]["value"]+"')"]
                outputs["Result"]["value"]+=" "+zoo._("Trigger in place")
            print >> sys.stderr,req
        for i in range(0,len(req)):
            if not(db.execute(req[i])):
                return zoo.SERVICE_FAILED
        db.conn.commit()
        return zoo.SERVICE_SUCCEEDED
    else:
        conf["lenv"]["message"]=zoo._("Unable to connect")
    return zoo.SERVICE_FAILED
开发者ID:mapmint,项目名称:mapmint,代码行数:29,代码来源:pgConnection.py

示例6: Intersection

def Intersection(conf,inputs,outputs):
    geometry1=extractInputs(conf,inputs["InputEntity1"])
    geometry2=extractInputs(conf,inputs["InputEntity2"])
    print >> sys.stderr, "***** 1: "+str(len(geometry1))+" 2: "+str(len(geometry2))
    rgeometries=[]
    fids=[]
    i=0
    for i in range(len(geometry1)):
        conf["lenv"]["message"]="("+str(i)+"/"+str(len(geometry1))+") "+zoo._("Running process...")
        zoo.update_status(conf,(i*100)/len(geometry1))
        j=0
        for j in range(len(geometry2)):
            tmp=geometry2[j].Clone()
            #resg=validateGeom(geometry2[j].GetGeometryRef())
            resg=geometry2[j].GetGeometryRef()
            #print >> sys.stderr," ***** 1 : "+str(resg)
            #resg=resg.Intersection(geometry1[i].GetGeometryRef())
            if len(geometry1)==1:
                conf["lenv"]["message"]="("+str(j)+"/"+str(len(geometry2))+") "+zoo._("Run intersection process...")
                zoo.update_status(conf,(j*100)/len(geometry2))
            if geometry1[i].GetGeometryRef().GetGeometryType()==osgeo.ogr.wkbMultiPolygon:
                for k in range(geometry1[i].GetGeometryRef().GetGeometryCount()):
                    try:
                        #tmpGeom=validateGeom(geometry1[i].GetGeometryRef().GetGeometryRef(k))
                        tmpGeom=geometry1[i].GetGeometryRef().GetGeometryRef(k)
                        if tmpGeom.Intersects(resg):
                            tmp1=geometry2[j].Clone()
                            #print >> sys.stderr," ***** 2 : "+str(resg)
                            resg1=tmpGeom.Intersection(resg)
                            #tmp1.SetGeometryDirectly(validateGeom(resg1))
                            tmp1.SetGeometryDirectly(resg1)
                            tmp1.SetFID(len(rgeometries))
                            if resg1 is not None and not(resg1.IsEmpty()):# and fids.count(tmp.GetFID())==0:
                                rgeometries+=[tmp1]
                                fids+=[tmp.GetFID()]
                            else:
                                tmp1.Destroy()
                    except Exception,e:
                        #tmp1.Destroy()
                        print >>sys.stderr,e
                tmp.Destroy()
            else:
                #print >> sys.stderr," ***** 2 : "+str(geometry1[i].GetGeometryRef())
                #resg=validateGeom(geometry1[i].GetGeometryRef()).Intersection(validateGeom(resg))
                #resg=validateGeom(geometry1[i].GetGeometryRef()).Intersection(resg)
                resg=geometry1[i].GetGeometryRef().Intersection(resg)
                #print >> sys.stderr," ***** 3 : "+str(resg)
                try:
                    #tmp.SetGeometryDirectly(validateGeom(resg))
                    tmp.SetGeometryDirectly(resg)
                    tmp.SetFID(len(rgeometries))
                    if resg is not None and not(resg.IsEmpty()):# and fids.count(tmp.GetFID())==0:
                        rgeometries+=[tmp]
                        fids+=[tmp.GetFID()]
                    else:
                        tmp.Destroy()
                except Exception,e:
                    print >>sys.stderr,e
开发者ID:mapmint,项目名称:mapmint,代码行数:58,代码来源:service.py

示例7: delete

def delete(conf,inputs,outputs):
	try: 
		#print >> sys.stderr, conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/"+inputs["name"]["value"]+".xml"
		os.unlink(conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/"+inputs["name"]["value"]+".xml")
	except:
		conf["lenv"]["message"]=zoo._("Unable to access the database configuration file to remove")
		return 4
	outputs["Result"]["value"]=zoo._("Database ")+inputs["name"]["value"]+zoo._(" was successfully removed from the Datastores")
	return 3
开发者ID:gislite,项目名称:mapmint,代码行数:9,代码来源:service.py

示例8: save

def save(conf,inputs,outputs):
	try: 
		f = open(conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/"+inputs["name"]["value"]+".txt", 'w')
	except:
		return 4
	try:
		f.write(inputs["url"]["value"]+"\n");
	except:
		return 4
	outputs["Result"]["value"]=zoo._("Data Store ")+inputs["name"]["value"]+zoo._(" created")
	return 3
开发者ID:mapmint,项目名称:mapmint,代码行数:11,代码来源:service.py

示例9: clogOut

def clogOut(conf,inputs,outputs):
	if conf.keys().count("senv")>0 and conf["senv"].keys().count("loggedin")>0 and conf["senv"]["loggedin"]=="true":
		outputs["Result"]["value"]=zoo._("User disconnected")
		conf["senv"]["loggedin"]="false"
		conf["senv"]["login"]="anonymous"
		return zoo.SERVICE_SUCCEEDED
	else:
		conf["lenv"]["message"]=zoo._("User not authenticated")
		return zoo.SERVICE_FAILED
	conf["lenv"]["message"]=zoo._("User not authenticated")
	return zoo.SERVICE_FAILED
开发者ID:ThomasG77,项目名称:mapmint,代码行数:11,代码来源:service.py

示例10: logOut

def logOut(conf,inputs,outputs):
	if conf.keys().count("senv")>0 and conf["senv"].keys().count("loggedin")>0 and conf["senv"]["loggedin"]=="true":
		outputs["Result"]["value"]=zoo._("User disconnected")
		conf["senv"]["loggedin"]="false"
		#conf["lenv"]["cookie"]="MMID=deleted; expires="+time.strftime("%a, %d-%b-%Y %H:%M:%S GMT",time.gmtime())+"; path=/"
		return zoo.SERVICE_SUCCEEDED
	else:
		conf["lenv"]["message"]=zoo._("User not authenticated")
		return zoo.SERVICE_FAILED
	conf["lenv"]["message"]=zoo._("User not authenticated")
	return zoo.SERVICE_FAILED
开发者ID:aristide,项目名称:mapmint,代码行数:11,代码来源:service.py

示例11: delete

def delete(conf,inputs,outputs):
	try: 
		os.unlink(conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/"+inputs["name"]["value"]+".txt")
	except:
		conf["lenv"]["message"]=zoo._("Unable to access the Data Store configuration file to remove")
		return 4
	try:
		os.unlink(conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/"+inputs["name"]["value"]+"ds_ows.map")
		os.unlink(conf["main"]["dataPath"]+"/"+inputs["type"]["value"]+"/"+inputs["name"]["value"]+".mmpriv")
	except:
		pass
	outputs["Result"]["value"]=zoo._("Database ")+inputs["name"]["value"]+zoo._(" was successfully removed from the Data Stores")
	return 3
开发者ID:mapmint,项目名称:mapmint,代码行数:13,代码来源:service.py

示例12: test

def test(conf,inputs,outputs):
    try:
        if inputs["type"]["value"].upper()=="WMS":
            import osgeo.gdal
            ds=osgeo.gdal.Open(inputs["type"]["value"]+":"+inputs["url"]["value"])
            ds.GetDriver()
        else:
            import osgeo.ogr
            ds=osgeo.ogr.Open(inputs["type"]["value"]+":"+inputs["url"]["value"])
            ds.GetDriver()
        outputs["Result"]["value"]=zoo._("Test connecting the Data Store ")+inputs["name"]["value"]+zoo._(" run successfully")
        return zoo.SERVICE_SUCCEEDED
    except Exception,e:
        conf["lenv"]["message"]=zoo._("Unable to access the Data Store:")+str(e)
        return zoo.SERVICE_FAILED
开发者ID:mapmint,项目名称:mapmint,代码行数:15,代码来源:service.py

示例13: clogOut

def clogOut(conf,inputs,outputs):
    if conf.keys().count("senv")>0 and conf["senv"].keys().count("loggedin")>0 and conf["senv"]["loggedin"]=="true":
        outputs["Result"]["value"]=zoo._("User disconnected")
        conf["senv"]["loggedin"]="false"
        conf["senv"]["login"]="anonymous"
        conf["senv"]["group"]="public"
        conf["lenv"]["ecookie_length"]="1"
        conf["lenv"]["ecookie"]="sid=empty"
        conf["lenv"]["cookie"]="MMID="+conf["lenv"]["usid"]+"; expires="+time.strftime("%a, %d-%b-%Y %H:%M:%S GMT",time.gmtime())+"; path=/"
        return zoo.SERVICE_SUCCEEDED
    else:
        conf["lenv"]["message"]=zoo._("User not authenticated")
        return zoo.SERVICE_FAILED
    conf["lenv"]["message"]=zoo._("User not authenticated")
    return zoo.SERVICE_FAILED
开发者ID:mapmint,项目名称:mapmint,代码行数:15,代码来源:service.py

示例14: GetUsersGroup

def GetUsersGroup(conf,inputs,outputs):
	if is_connected(conf):
		c = auth.getCon(conf)
		if not re.match(r"(^\d+$)",inputs["id"]["value"]):
			conf["lenv"]["message"] = zoo._("Parametre id incorrect")
			return 4
		if c.is_admin(conf["senv"]["login"]):
			outputs["Result"]["value"] = json.dumps(c.get_users_group_by_id(int(inputs["id"]["value"]),inputs["order"]["value"],inputs["sort"]["value"]))
			return 3
		else:
			conf["lenv"]["message"]= zoo._("Action not permited")
			return 4
	else:
		conf["lenv"]["message"]=zoo._("User not authenticated")
		return 4
开发者ID:ablayelana,项目名称:mapmint,代码行数:15,代码来源:service_users.py

示例15: addSymbolToOrig

def addSymbolToOrig(conf,inputs,outputs):
    import sys
    from Cheetah.Template import Template
    f=open(conf["main"]["dataPath"]+"/symbols.sym","r")
    newContent=""
    str=f.read()
    f.close()
    i=0
    b=str.split('SYMBOL\n')
    for a in b:
        if a!="" and a!='\n':
            if i+1 < len(b):
                if newContent!="":
                    newContent+='SYMBOL\n'+a
                else:
                    newContent+=a
            else:
                print >> sys.stderr,a[:len(a)-4]
                newContent+='SYMBOL\n'+a[:len(a)-5]
            i+=1
    t=Template(file=conf["main"]["templatesPath"]+"/Manager/Styler/Symbols.sym.tmpl",searchList={"conf": conf,"inputs": inputs,"outputs": outputs})
    newContent+=t.__str__().replace('SYMBOLSET\n',"")
    f=open(conf["main"]["dataPath"]+"/symbols.sym","w")
    f.write(newContent)
    f.close()
    outputs["Result"]["value"]=zoo._("Symbol added.")
    return 3
开发者ID:ThomasG77,项目名称:mapmint,代码行数:27,代码来源:service.py


注:本文中的zoo._函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。