From: Sergio F. <se...@wi...> - 2012-09-12 08:38:18
|
Hi again, today I'm quite busy, so I can't go deeper into SuRF's source code. Could you please provide me details about the trace how resource_d is build at [1]? Because you're directly using results["results"]["bindings"], that's a list, so it's wrong (this code will not work [2], for instance) and will produce the reported exception even with results. It should access a concrete binding of the results (as this code does [3]). Awaiting for your support on that. Cheers, [1] http://code.google.com/p/surfrdf/source/browse/trunk/surf/resource/__init__.py#548 [2] http://gist.github.com/3705188 [3] http://gist.github.com/3705219 On 12 September 2012 09:53, Sergio Fernández <se...@wi...> wrote: > Hi Laurens, > > when SuRF performs: > >> "c:\python27-32\lib\site-packages\surf-1.1.6r0_r374-py2.7.egg\surf\resource\__init__.py" >> in __set_predicate_values >> 571. for p, v in results.items(): > > it's because to get a dictionary there, but a list was returned. I'll > investigate why such container is returned when the result set comes > empty, because that's something that should be handle by the library. > > I'll keep you informed. > > Kind regards, > > > On 11 September 2012 11:15, Laurens De Vocht <lau...@gm...> wrote: >> >> Hi, >> >> >> When I switched from the Allegrograph SurfRDF to SPARQLWrapper SurfRDF, I >> suddenly get this error (both with Virtuoso and Fuseki SPARQL Endpoints): >> >> Environment: >> >> >> Request Method: GET >> Request URL: http://localhost:8000/leden/done/ >> >> Django Version: 1.4.1 >> Python Version: 2.7.3 >> Installed Applications: >> ('django.contrib.auth', >> 'django.contrib.contenttypes', >> 'django.contrib.sessions', >> 'django.contrib.sites', >> 'django.contrib.messages', >> 'django.contrib.staticfiles', >> 'social_auth', >> 'twitter', >> 'surf', >> 'hamlpy', >> 'djaml', >> 'django.contrib.admin', >> 'leden') >> Installed Middleware: >> ('django.middleware.common.CommonMiddleware', >> 'django.contrib.sessions.middleware.SessionMiddleware', >> 'django.middleware.csrf.CsrfViewMiddleware', >> 'django.contrib.auth.middleware.AuthenticationMiddleware', >> 'django.contrib.messages.middleware.MessageMiddleware') >> >> >> Traceback: >> File "C:\Python27-32\lib\site-packages\django\core\handlers\base.py" in >> get_response >> 111. response = callback(request, >> *callback_args, **callback_kwargs) >> File "C:\Python27-32\lib\site-packages\django\contrib\auth\decorators.py" >> in _wrapped_view >> 20. return view_func(request, *args, **kwargs) >> File >> "C:\Users\ldevocht\git\DynResAlignRepo\dynresalign\leden\profiler\persistence.py" >> in addUserAccountToPerson >> 189. person.load() >> File >> "c:\python27-32\lib\site-packages\surf-1.1.6r0_r374-py2.7.egg\surf\resource\__init__.py" >> in load >> 548. self.__set_predicate_values(results_d, True) >> File >> "c:\python27-32\lib\site-packages\surf-1.1.6r0_r374-py2.7.egg\surf\resource\__init__.py" >> in __set_predicate_values >> 571. for p, v in results.items(): >> >> Exception Type: AttributeError at /leden/done/ >> Exception Value: 'list' object has no attribute 'items' >> >> I assume that results.items() is something that comes from the >> SPARQLWrapper en then handled by SurfRDF. However it is impossible for me to >> tell what exactly happens when an empty result is being returned in >> SPARQLWrapper. >> >> The code that handles this is: >> >> def __set_predicate_values(self, results, direct): >> """ set the prediate - value(s) to the resource using lazy >> loading, >> `results` is a dict under the form: >> {'predicate':{'value':[concept,concept],...},...}. >> >> """ >> >> for p, v in results.items(): >> attr = rdf2attr(p, direct) >> value = self._lazy(v) >> if value: >> self.__setattr__(attr, value) So I assume that if >> SPARQLWrapper makes sure that the results or the results.items() object is >> never simply empty or that the results have always at least an attribute >> items this issue can be resolved even when the results are empty (which is >> obviously the case here).v >> Any comments on this issue or at least a workaround or something? >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> sparql-wrapper-devel mailing list >> spa...@li... >> https://lists.sourceforge.net/lists/listinfo/sparql-wrapper-devel >> > > > > -- > > Sergio Fernández <se...@wi...> -- Sergio Fernández <se...@wi...> |