On 04/26/12 14:33, Phil Charlesworth wrote:
The 404 file not found comes only if the images are not present in
/public/. If they are, I get 200.
In either case the application works OK as long as the lines
elif pyjd.is_desktop:
return pyjd.pyjdinitpth + "/library/pyjamas/ui/public/"
are present in pygwt.getImageBaseURL()
If I comment those lines out, the application can only find the images
if they are in /public/.
So we are right back to the start of this issue and the reason for the
changes. Without those two lines of code, DisclosurePanel and Tree
would not show their images under pyjd unless you copied them from
library/pyjamas/ui/public/ to your application's public directory. But
that was a difference from pyjs, because pyjs /automatically/ copies
them from library/pyjamas/ui/public/ to the application's /output/
directory.
So, I think perhaps Luke's suggestion that pyjd should somehow do the
same is perhaps the best idea.
However, it is the case that the current code works, in the sense that
there is nothing wrong with the application's screen output or
function -- it's just that the server puts out a 404 status for the
image that's present in the startup screen instead of 200. The other
images don't provoke HTTP transactions at all.
I still sense that I have not exactly reproduced your experience. With
your original index.py it was difficult to tell whether the
application was functioning correctly because the only image it should
show is image_white.gif and it doesn't do anything when you click it.
I would be interesting to know whether my modified index.py produces
the right output for you if you retain the elif pyd.is_desktop: option
in pygwt.getImageBaseURL()
Phil
I have tried your index.py, with almost the same result - wrong (full
system) paths are requested, and no images are shown.
However I noticed that one image was now indeed (successfully) requested
from public/tree_closed.gif once. But was yet not shown. Here is my full
log:
-----
$ ./server.py
localhost - - [26/Apr/2012 14:53:04] "GET /public/index.html HTTP/1.1" 200 -
localhost - - [26/Apr/2012 14:53:04] code 404, message File not found
localhost - - [26/Apr/2012 14:53:04] "GET
/home/seva/pyjamas/library/pyjamas/ui/public/tree_white.gif HTTP/1.1" 404 -
localhost - - [26/Apr/2012 14:53:04] "GET /public/tree_closed.gif
HTTP/1.1" 200 -
localhost - - [26/Apr/2012 14:53:04] code 404, message File not found
localhost - - [26/Apr/2012 14:53:04] "GET
/home/seva/pyjamas/library/pyjamas/ui/public/tree_closed.gif HTTP/1.1" 404 -
localhost - - [26/Apr/2012 14:53:05] code 404, message File not found
localhost - - [26/Apr/2012 14:53:05] "GET
/home/seva/pyjamas/library/pyjamas/ui/public/tree_open.gif HTTP/1.1" 404 -
localhost - - [26/Apr/2012 14:53:06] code 404, message File not found
localhost - - [26/Apr/2012 14:53:06] "GET
/home/seva/pyjamas/library/pyjamas/ui/public/tree_open.gif HTTP/1.1" 404 -
localhost - - [26/Apr/2012 14:53:07] code 404, message File not found
localhost - - [26/Apr/2012 14:53:07] "GET
/home/seva/pyjamas/library/pyjamas/ui/public/tree_closed.gif HTTP/1.1" 404 -
-----
And I have these images in public/ folder: public/tree_open.gif,
public/tree_closed.gif etc.
However, I had to replace line
pyjd.setup("http://localhost/examples/seva/public/index.html")
with line
pyjd.setup("http://localhost:8080/public/index.html")
I attached resulting index.py.
If you tried your version, with http://localhost/ whithout :8080 part,
may be your client connected to your apache again, not to server.py?
server.py listen on 8080 port, if you did not change that.
And I think I know where this /public/tree_closed.git hit came from:
There is a code In library/pyjamas/ui/TreeItem.py:293:
def imgSrc(self, img):
if self.tree is None:
return img
src = self.tree.getImageBase() + img
return src
So it is tree_closed.gif tries to show itself without TreeItem's
self.tree assigned yet.
Seva
# -*- coding: utf-8 -*-
import pyjd # this is dummy in pyjs.
from pyjamas.ui.HTML import HTML
from pyjamas.ui.Button import Button
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.Timer import Timer
from pyjamas.JSONService import JSONProxy
class Test:
def __init__( self ):
self.svc = JSONProxy('svc', ['echo'])
RootPanel().add(Button('make ajax call', self.makeAjaxCall))
RootPanel().add(Button('make ajax call after 1s', self.scheduleCall))
self.makeAjaxCall() # will fail
self.scheduleCall()
def makeAjaxCall( self, *args, **kw ):
self.svc.echo(self, 'test arg')
def scheduleCall( self, *args ):
Timer(notify=self.makeAjaxCall, delayMillis=1000)
def log( self, msg ):
RootPanel().add(HTML(msg))
def onRemoteResponse( self, response, request_info ):
self.log('server responded: %r' % response)
def onRemoteError( self, code, errobj, request_info ):
message = errobj['message']
if code != 0:
self.log("HTTP error %d: %s" % (code, message))
else:
code = errobj['code']
self.log("JSONRPC Error %s: %s" % (code, message))
def main():
pyjd.setup("http://localhost:8080/index.html")
test = Test()
pyjd.run()
main()