[Twisted-web] css File with Nevow

dsalvatore at freesurf.fr dsalvatore at freesurf.fr
Fri Nov 18 04:18:06 MST 2005


Grazie Valentino :-)

> On Thu, Nov 17, 2005 at 10:10:38PM +0100, dsalvatore at freesurf.fr wrote:
>> Hello,
>>
>> I would like to use an externel xml file linked to a style sheet
>>
>> <html xmlns:nevow="http://nevow.com/ns/nevow/0.1">
>> <head>
>> <link rel="stylesheet" href="style.css" type="text/css" />
>> </head>
>> .......
>>
>> The problem is that the syle sheet is not teken in account.
>> Could someone tell me how to proceed ?
>
> you have to manually export the file to the Nevow object tree.
>
> from nevow import rend, static
> class MyPage(rend.Page):
>    child_css = static.File('on_filesystem_css_directory/')
>
> This will export the entire content of the on_filesystem_css_directory/
> in an 'online' directory named css/ so considering MyPage as the root
> page (in /) the css will be in /css/style.css
>
> If you really want stuff like 'style.css' at root level you have 2
> choices:
>
> put in the class the dictionary:
>
> class MyPage(rend.Page):
>   children = { 'style.css':
>                static.File('on_filesystem_css_directory/cssfile.css')
>   }
>
> or
>
> class MyPage(rend.Page):
>   setattr(MyPage, 'child_style.css', static.File('on_file.......'))
>
> HTH
>
> --
> Valentino Volonghi aka Dialtone
> Now Running MacOSX 10.4
> Blog: http://vvolonghi.blogspot.com
> http://weever.berlios.de






More information about the Twisted-web mailing list