Re: Data Wiki directory broken

It might break from too much badly formatted SPARQL until C++ error 
handling is worked out though our errors today were caused by some 
renaming Eric did in the SWObjects API.

I fixed the calls (s/POSFactory/AtomFactory and 
s/assureGraph/ensureGraph) and decoupled the wiki from the SWObjects 
compilation stack to prevent these kinds of errors in the future.

(Any thoughts on rdfWidgets editing/ACLs in the directory indexes?)

Index: __post.py
===================================================================
--- __post.py   (revision 29511)
+++ __post.py   (working copy)
@@ -6,13 +6,13 @@

  import SWObjects
  def update(n3, query, base_uri=''):
-    _F = SWObjects.POSFactory()
+    _F = SWObjects.AtomFactory()
      _DB = SWObjects.RdfDB()

      # Parse existing N3
      if n3:
          _T = SWObjects.TurtleSDriver(base_uri, _F)
-        _T.setGraph(_DB.assureGraph(SWObjects.cvar.DefaultGraph))
+        _T.setGraph(_DB.ensureGraph(SWObjects.cvar.DefaultGraph))
          _T.parse(SWObjects.IStreamContext(n3, 
SWObjects.StreamContextIstream.STRING))


Tim Berners-Lee wrote:
> Just today, Two compounded errors.
> 
> 1) The SWOBJECT link to python seems to have died.
> 2) When the server produced that error message, it did it with a 200 
> return code, instead of an error code.  So the tabulator ignores the 
> problem and behaves as though the data has been written back.
> 
> This was working yesterday.
> 
> Could I have broken it by sending badly formatted SPARQL?
> 
> Tim
> 
> 
> $ curl -i -d 'INSERT { 
> <http://dig.xvm.mit.edu/wiki/people/JoeLambda#JL>  
> <http://xmlns.com/foaf/0.1/age> 66 }'  -H 
> Content-type:application/sparql-query   
> http://dig.xvm.mit.edu/wiki/people/JoeLambda
> 
> HTTP/1.1 200 OK
> Date: Sun, 08 Aug 2010 16:48:45 GMT
> Server: Apache
> Vary: Content-Type
> MS-Author-Via: SPARQL
> Access-Control-Allow-Origin: *
> Access-Control-Allow-Methods: GET,PUT,POST,OPTIONS
> Access-Control-Allow-Headers: X-Requested-With
> Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
> pre-check=0
> Pragma: no-cache
> Connection: close
> Transfer-Encoding: chunked
> Content-Type: text/html; charset=UTF-8
> 
> <body bgcolor="#f0f0f8">
> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
> <tr bgcolor="#6622aa">
> <td valign=bottom>&nbsp;<br>
> <font color="#ffffff" face="helvetica, 
> arial">&nbsp;<br><big><big><strong>&lt;type 
> 'exceptions.AttributeError'&gt;</strong></big></big></font></td
>  ><td align=right valign=bottom
>  ><font color="#ffffff" face="helvetica, arial">Python 2.6.4: 
> /usr/bin/python<br>Sun Aug  8 12:48:45 2010</font></td></tr></table>
> 
>     
> 
> <p>A problem occurred in a Python script.  Here is the sequence of
> function calls leading up to the error, in the order they occurred.</p>
> <table width="100%" cellspacing=0 cellpadding=0 border=0>
> <tr><td bgcolor="#d8bbff"><big>&nbsp;</big><a 
> href="file:///usr/lib/python2.6/site-packages/flup/server/fcgi_base.py">/usr/lib/python2.6/site-packages/flup/server/fcgi_base.py</a> 
> in <strong>run</strong>(self=&lt;flup.server.fcgi_base.Request object at 
> 0x7f13700dc350&gt;)</td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;556</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"""Runs&nbsp;the&nbsp;handler,&nbsp;flushes&nbsp;the&nbsp;streams,&nbsp;and&nbsp;ends&nbsp;the&nbsp;request."""<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;557</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
> </tt></font></td></tr>
> <tr><td 
> bgcolor="#ffccee"><tt><small>&nbsp;&nbsp;558</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protocolStatus,&nbsp;appStatus&nbsp;=&nbsp;self.server.handler(self)<br>
> </tt></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;559</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except:<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;560</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;traceback.print_exc(file=self.stderr)<br>
> </tt></font></td></tr>
> <tr><td><small><font color="#909090">protocolStatus <em>undefined</em>, 
> appStatus <em>undefined</em>, <strong>self</strong>&nbsp;= 
> &lt;flup.server.fcgi_base.Request object at 0x7f13700dc350&gt;, 
> self.<strong>server</strong>&nbsp;= &lt;flup.server.fcgi.WSGIServer 
> object at 0x332abd0&gt;, self.server.<strong>handler</strong>&nbsp;= 
> &lt;bound method WSGIServer.handler of &lt;flup.server.fcgi.WSGIServer 
> object at 0x332abd0&gt;&gt;</font></small></td></tr></table>
> <table width="100%" cellspacing=0 cellpadding=0 border=0>
> <tr><td bgcolor="#d8bbff"><big>&nbsp;</big><a 
> href="file:///usr/lib/python2.6/site-packages/flup/server/fcgi_base.py">/usr/lib/python2.6/site-packages/flup/server/fcgi_base.py</a> 
> in <strong>handler</strong>(self=&lt;flup.server.fcgi.WSGIServer object 
> at 0x332abd0&gt;, req=&lt;flup.server.fcgi_base.Request object at 
> 0x7f13700dc350&gt;)</td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;1116</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;1117</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
> </tt></font></td></tr>
> <tr><td 
> bgcolor="#ffccee"><tt><small>&nbsp;1118</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result&nbsp;=&nbsp;self.application(environ,&nbsp;start_response)<br>
> </tt></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;1119</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;1120</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;data&nbsp;in&nbsp;result:<br>
> </tt></font></td></tr>
> <tr><td><small><font color="#909090"><strong>result</strong>&nbsp;= 
> None, <strong>self</strong>&nbsp;= &lt;flup.server.fcgi.WSGIServer 
> object at 0x332abd0&gt;, self.<strong>application</strong>&nbsp;= 
> &lt;function handler at 0x2f8e410&gt;, <strong>environ</strong>&nbsp;= 
> {'CONTENT_LENGTH': '96', 'CONTENT_TYPE': 'application/sparql-query', 
> 'DOCUMENT_ROOT': '/srv/dig/www', 'GATEWAY_INTERFACE': 'CGI/1.1', 
> 'HTTP_ACCEPT': '*/*', 'HTTP_CONNECTION': 'close', 'HTTP_HOST': 
> 'dig.xvm.mit.edu', 'HTTP_USER_AGENT': 'curl/7.19.7 
> (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3', 
> 'PATH': '/sbin:/usr/sbin:/bin:/usr/bin', 'PATH_INFO': 
> '/wiki/people/JoeLambda', ...}, <strong>start_response</strong>&nbsp;= 
> &lt;function start_response at 
> 0x7f13700bdaa0&gt;</font></small></td></tr></table>
> <table width="100%" cellspacing=0 cellpadding=0 border=0>
> <tr><td bgcolor="#d8bbff"><big>&nbsp;</big><a 
> href="file:///srv/dig/www/wiki/__post.py">/srv/dig/www/wiki/__post.py</a> 
> in <strong>handler</strong>(environ={'CONTENT_LENGTH': '96', 
> 'CONTENT_TYPE': 'application/sparql-query', 'DOCUMENT_ROOT': 
> '/srv/dig/www', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': '*/*', 
> 'HTTP_CONNECTION': 'close', 'HTTP_HOST': 'dig.xvm.mit.edu', 
> 'HTTP_USER_AGENT': 'curl/7.19.7 (universal-apple-darwin10.0) 
> libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3', 'PATH': 
> '/sbin:/usr/sbin:/bin:/usr/bin', 'PATH_INFO': '/wiki/people/JoeLambda', 
> ...}, start_response=&lt;function start_response at 
> 0x7f13700bdaa0&gt;)</td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;37</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;os.path.exists(abs_path+'.n3'):<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;38</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n3&nbsp;=&nbsp;file(abs_path+'.n3').read()<br>
> </tt></font></td></tr>
> <tr><td 
> bgcolor="#ffccee"><tt><small>&nbsp;&nbsp;&nbsp;39</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r&nbsp;=&nbsp;update(n3,&nbsp;query,&nbsp;base_uri)<br>
> </tt></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;40</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file(abs_path+'.n3',&nbsp;'w').write(r)<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;41</small>&nbsp;<br>
> </tt></font></td></tr>
> <tr><td><small><font color="#909090">r <em>undefined</em>, 
> <em>global</em> <strong>update</strong>&nbsp;= &lt;function update at 
> 0x7f137d5b3c80&gt;, <strong>n3</strong>&nbsp;= 
> '&lt;http://example.edu/2007/wiki/people/JoeLambda#J... "This is a 
> comment whcih Tim put in at 22:48" .<font color="#c040c0">\n</font>', 
> <strong>query</strong>&nbsp;= 'INSERT { 
> &lt;http://dig.xvm.mit.edu/wiki/people/JoeLambda#JL&gt;  
> &lt;http://xmlns.com/foaf/0.1/age&gt; 66 }', 
> <strong>base_uri</strong>&nbsp;= 
> 'http://dig.xvm.mit.edu/wiki/people/JoeLambda'</font></small></td></tr></table>
> <table width="100%" cellspacing=0 cellpadding=0 border=0>
> <tr><td bgcolor="#d8bbff"><big>&nbsp;</big><a 
> href="file:///srv/dig/www/wiki/__post.py">/srv/dig/www/wiki/__post.py</a> 
> in 
> <strong>update</strong>(n3='&lt;http://example.edu/2007/wiki/people/JoeLambda#J... 
> "This is a comment whcih Tim put in at 22:48" .<font 
> color="#c040c0">\n</font>', query='INSERT { 
> &lt;http://dig.xvm.mit.edu/wiki/people/JoeLambda#JL&gt;  
> &lt;http://xmlns.com/foaf/0.1/age&gt; 66 }', 
> base_uri='http://dig.xvm.mit.edu/wiki/people/JoeLambda')</td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;&nbsp;7</small>&nbsp;import&nbsp;SWObjects<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;&nbsp;8</small>&nbsp;def&nbsp;update(n3,&nbsp;query,&nbsp;base_uri=''):<br>
> </tt></font></td></tr>
> <tr><td 
> bgcolor="#ffccee"><tt><small>&nbsp;&nbsp;&nbsp;&nbsp;9</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_F&nbsp;=&nbsp;SWObjects.POSFactory()<br>
> </tt></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;10</small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_DB&nbsp;=&nbsp;SWObjects.RdfDB()<br>
> </tt></font></td></tr>
> <tr><td><font 
> color="#909090"><tt><small>&nbsp;&nbsp;&nbsp;11</small>&nbsp;<br>
> </tt></font></td></tr>
> <tr><td><small><font color="#909090">_F <em>undefined</em>, 
> <em>global</em> <strong>SWObjects</strong>&nbsp;= &lt;module 'SWObjects' 
> from '/srv/dig/lib/python/SWObjects.py'&gt;, SWObjects.POSFactory 
> <em>undefined</em></font></small></td></tr></table><p><strong>&lt;type 
> 'exceptions.AttributeError'&gt;</strong>: 'module' object has no 
> attribute 'POSFactory'
> <br><tt><small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</small>&nbsp;</tt>args&nbsp;=
> ("'module' object has no attribute 'POSFactory'",)
> <br><tt><small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</small>&nbsp;</tt>message&nbsp;=
> "'module' object has no attribute 'POSFactory'"
> 
> 
> <!-- The above is a description of an error in a Python program, formatted
>      for a Web browser because the 'cgitb' module was enabled.  In case you
>      are not reading this in a Web browser, here is the original traceback:
> 
> Traceback (most recent call last):
>   File "/usr/lib/python2.6/site-packages/flup/server/fcgi_base.py", line 
> 558, in run
>     protocolStatus, appStatus = self.server.handler(self)
>   File "/usr/lib/python2.6/site-packages/flup/server/fcgi_base.py", line 
> 1118, in handler
>     result = self.application(environ, start_response)
>   File "/srv/dig/www/wiki/__post.py", line 39, in handler
>     r = update(n3, query, base_uri)
>   File "/srv/dig/www/wiki/__post.py", line 9, in update
>     _F = SWObjects.POSFactory()
> AttributeError: 'module' object has no attribute 'POSFactory'
> 
> -->
> 

Received on Monday, 9 August 2010 09:25:28 UTC