On Feb 17, 2011, at 10:37 AM, Johann Spies wrote:
> What are the actual URLs for the images in question? As they appear in the 
> page source at the browser, I mean.
> 
> 
> src="/kb/static/DSC_1403.png" (I moved the image from /kb/static/images to 
> /kb/static - now it works. 
> 
>  I would still like to know how to get imgages in static/images to work with 
> this routing system.
> 
> 
> src="/sadec/static/sadc.png" 

It should "just work". Can you double-check your names?

Also, please try it (with files in static/images) with routing turned off 
(rename routes.py and restart web2py).

If that doesn't resolve things, I'll try a more extended test at my end.

I wrote a unit test, below, that seems to work OK. The extra kb & sadec router 
entries are there because the apps aren't in my file system; you don't need 
them.

    def test_johann_spies(self):
        '''
        test Johann Spies router
        '''
        router_js = dict(
            BASE = dict(
                default_application = 'kb',
                domains = {
                        'kbase.sun.ac.za' : 'kb',
                        'kbase' : 'kb',
                        'sadcpublications.sun.ac.za' : 'sadec'
                },
                applications = ['kb', 'sadec'],
            ),
            kb = dict(),
            sadec = dict(),
        )
        load(rdict=router_js)
        self.assertEqual(filter_url('http://kbase.sun.ac.za/'), 
            '/kb/default/index')
        self.assertEqual(filter_url('http://kbase/'), 
            '/kb/default/index')
        self.assertEqual(filter_url('http://sadcpublications.sun.ac.za/'), 
            '/sadec/default/index')
        self.assertEqual(filter_url('http://kbase.sun.ac.za/static/file.css'), 
            '%s/applications/kb/static/file.css' % root)
        self.assertEqual(filter_url('http://kbase.sun.ac.za/static/file.css'), 
            '%s/applications/kb/static/file.css' % root)
        
self.assertEqual(filter_url('http://kbase.sun.ac.za/static/DSC_1403.png'), 
            '%s/applications/kb/static/DSC_1403.png' % root)
        
self.assertEqual(filter_url('http://kbase.sun.ac.za/static/images/DSC_1403.png'),
 
            '%s/applications/kb/static/images/DSC_1403.png' % root)
        self.assertEqual(filter_url('http://kbase/static/images/DSC_1403.png'), 
            '%s/applications/kb/static/images/DSC_1403.png' % root)

Reply via email to