[Grok-dev] Newbie question: adding static document at site root?
Pete Hunt
floydophone at gmail.com
Tue Sep 23 23:32:02 EDT 2008
Thanks everyone - the ZMI solution was what I was looking for, but I had
already taken Sebastian's advice and now I'm serving everything behind
nginx, which was easier than I thought it would be.
Thanks!
On Tue, Sep 23, 2008 at 7:58 PM, Uli Fouquet <uli at gnufix.de> wrote:
> Hi there,
>
> Pete Hunt wrote:
>
> > I'm developing a Flash/Flex application which communicates with Grok
> > via AMF. The problem is, in order for the security to work, I need to
> > add a crossdomain.xml file to the site root
> > (http://host/crossdomain.xml). Unfortunately, I can only create views
> > off of my application's path (http://host/myapp/blah), and I can't for
> > the life of me figure out how to add a static file via the ZMI to the
> > site root.
>
> Michael told you already how to add a File-object to the root folder
> using the ZMI. There are, however, also some non-ZMI ways available.
>
> You could register a file in your `configure.zcml` like this::
>
> <configure
> ...
> <browser:resource
> file="somedir/foo.xml"
> name="crossdomain.xml" />
> </configure>
>
> which would make the file `foo.xml` located in the `somedir` directory
> of your package available under the name `crossdomain.xml`.
>
> The URLs
>
> http://<host>/@@/crossdomain.xml
>
> or
>
> http://<host>/++resource++crossdomain.xml
>
> would then deliver foo.xml with the correct filetype etc.
>
> Another, 'dirtier', approach would be to define a new view on root
> folders in your Grok application like this::
>
> from zope.app.folder.interfaces import IRootFolder
> import grok
>
> class Crossdomain(grok.View):
> grok.context(IRootFolder)
> grok.name('crossdomain.xml')
>
> def render(self):
> self.response.setHeader('Content-Type',
> 'text/xml; charset=UTF-8')
> return "<doc>Some XML</doc>"
>
> Here you could get the file contents like this::
>
> http://<host>/crossdomain.xml
>
> which is the short form for
>
> http://<host>/@@crossdomain.xml
>
> Given you have no object named 'crossdomain.xml' in your root folder,
> the short form would return your view, i.e. your XML content. Hm, there
> are even more approaches, but that may help for now.
>
> Best regards,
>
> --
> Uli
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20080923/acb89aef/attachment.html
More information about the Grok-dev
mailing list