# HG changeset patch # User dwinter # Date 1355444945 18000 # Node ID 3532f1c49efb8498bf03ad3e455fe36bbf9bdc0c # Parent e6c3334e9611a4dfd26789d7fa18f32c3f71843e changes for new apu diff -r e6c3334e9611 -r 3532f1c49efb .pydevproject --- a/.pydevproject Wed May 30 16:53:45 2012 +0200 +++ b/.pydevproject Thu Dec 13 19:29:05 2012 -0500 @@ -2,6 +2,6 @@ -Default +python2.7_zope python 2.7 diff -r e6c3334e9611 -r 3532f1c49efb JSONClient.py --- a/JSONClient.py Wed May 30 16:53:45 2012 +0200 +++ b/JSONClient.py Thu Dec 13 19:29:05 2012 -0500 @@ -8,6 +8,8 @@ import os.path import logging +from lxml import etree + from BTrees.OOBTree import OOBTree class JSONClient(SimpleItem): @@ -42,7 +44,7 @@ def getEntityLink(self,entId): - return "https://openmind-ismi-dev.mpiwg-berlin.mpg.de/om4-ismi/browse/entityDetails.iface?eid="+str(entId) + return "https://openmind-ismi-dev.mpiwg-berlin.mpg.de/om4-ismi/browse/entityDetails.xhtml?eid="+str(entId) def json(self,method,params={},cache=True): """json aufruf""" @@ -64,28 +66,29 @@ def mapEntityAttributesToData(self,entity,type): - attrs=entity.get('attributes') + logging.debug(entity) + attrs=entity.get('atts') attrsHash={} for attr in attrs: - attrsHash[attr.get('name')]=attr.get('ownValue') + attrsHash[attr.get('name')]=attr.get('ov') attrsHash['@type']=type return attrsHash def getOV(self,entId): if (entId)<0: #-1 falls keine Entity gefunden wurde return"" - obj=self.json("getEntity", {'entId':entId}) - return obj.get('entity').get('ownValue') + obj=self.json("get_ent", {'id':entId}) + return obj.get('ent').get('ov') - def getSingleRelationFromEntity(self,jsonHash,type="srcRelations",relName=None,idType="sourceId"): + def getSingleRelationFromEntity(self,jsonHash,type="src_Rrels",relName=None,idType="src_id"): ret = self.getRelationFromEntity(jsonHash,type,relName,maxNum=1) if len(ret)==0: return -1 else: return ret[0].get(idType) - def getRelationFromEntity(self,jsonHash,type="srcRelations",relName=None,maxNum=30): - hash=jsonHash.get("entity") + def getRelationFromEntity(self,jsonHash,type="src_rels",relName=None,maxNum=3000): + hash=jsonHash.get("ent") logging.debug(type) logging.debug(".................") logging.debug(hash) @@ -263,6 +266,45 @@ self._v_jsonCache.update({cacheName:caches}) return hash.get(letter,[]), hash.keys() + + + def xsltTransform(self,path=None,pathXML=None,pathXSL=None,entID=None): + """xlst""" + if path is not None: + pathXML=path+".xml" + pathXSL=path+".xsl" + + + logging.debug(pathXML) + logging.debug(pathXSL) + + url=self.REQUEST['URL2'] + xmlURL=url+pathXML + xslURL=url+pathXSL + + + + logging.debug(xmlURL) + logging.debug(xslURL) + + + + f= urllib.urlopen(xslURL); + txt= f.read() + xslt_root=etree.fromstring(txt) + #xslt_root= etree.parse(xslURL) #verstehe nicht warum das nicht geht?? + + f= urllib.urlopen(xmlURL+"?id="+entID); + txt= f.read() + xml=etree.fromstring(txt) + #xml= etree.parse(xmlURL+"?id="+entID) + + transform=etree.XSLT(xslt_root) + + + result =transform(xml) + return unicode(result) + def manage_addJSONClient(self,id,url,RESPONSE=None): """add a json client""" @@ -280,7 +322,9 @@ pt=zptFile(self, 'zpt/AddJSONClientForm.zpt') return pt() - + + + def zptFile(self, path, orphaned=False): """returns a page template file from the product""" if orphaned: