Hi all

I have some problem with my script

I try to use this example in turbogears 2.3.8

# -*- coding: utf-8 -*-
from tg.controllers.tgcontroller import TGController
from tg.predicates import not_anonymous
from tg import expose, config
import os

try:
    from tg.controllers import WSGIAppController
except ImportError:
    from tg.controllers.wsgiappcontroller import WSGIAppController

try:
    from paste.urlparser import StaticURLParser
except ImportError:
    from  webob.static import DirectoryApp as StaticURLParser

                                                                       
class PrivateStatics(TGController):                                    
    @expose()                                                          
    def lookup(self, *args):                                           
        site_dir = os.path.join(config.get('here'), '/myapp/private')
        return WSGIAppController(StaticURLParser(site_dir), allow_only=
not_anonymous()), args
                                                                       
    _lookup = lookup

and I got the error:

RuntimeError: Mounting nested WSGI apps requires make_body_seekable=True 
option

what am I doing wrong or how can I set this option ?

W dniu poniedziałek, 18 czerwca 2012 22:28:58 UTC+2 użytkownik Alessandro 
Molina napisał:
>
> Static files are served by a middleware in the WSGI chain, 
> this runs before the authentication layer got in, so it doesn't have 
> any knowledge of users. 
>
> You can roll your own statics serving controller which checks users 
> and so on, a minima solution can be: 
>
> class StaticsController(TGController): 
>     @expose() 
>     def _lookup(self, *args): 
>         return WSGIAppController(StaticURLParser(statics_path)), args 
>
> On Mon, Jun 18, 2012 at 2:39 PM, abc_coder <[email protected] 
> <javascript:>> wrote: 
> > Hi all 
> > 
> > I searched a lot but haven’t found any solution. How can I in turgobears 
> 2 
> > restrict access to static files only for logged users? 
> > I want add some protection from unlogged users and web robots. 
> > 
> > Please help. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "TurboGears" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/turbogears/-/a6oOER4Ps3cJ. 
> > To post to this group, send email to [email protected] 
> <javascript:>. 
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:>. 
> > For more options, visit this group at 
> > http://groups.google.com/group/turbogears?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to