[Repoze-dev] tg.repoze.who and ProxyPass
percious
percious17 at gmail.com
Mon May 12 15:40:13 EDT 2008
Right, so I have been tried that, and it looks like repoze is running
in a different thread. IE I get :No object (name: repoze.who
RedirectFormPlugin) has been registered for this thread.
Here is my diff:
--- plugins/form.py (revision 1032)
+++ plugins/form.py (working copy)
@@ -11,6 +11,8 @@
from paste.request import parse_formvars
from paste.request import construct_url
+from paste.registry import StackedObjectProxy, Registry
+
from zope.interface import implements
from repoze.who.interfaces import IChallenger
@@ -119,10 +121,17 @@
return auth_form
+class RequestLocal(object):
+ def __init__(self, environ):
+ self.environ = environ
+
class RedirectingFormPlugin(FormPluginBase):
implements(IChallenger, IIdentifier)
+ request_local = StackedObjectProxy(name="repoze.who
RedirectFormPlugin")
+ request_local_class = request_local
+
def __init__(self, login_form_url, login_handler_path,
logout_handler_path,
rememberer_name):
self.login_form_url = login_form_url
@@ -176,6 +185,16 @@
query_elements['came_from'] = came_from
url_parts[4] = urllib.urlencode(query_elements, doseq=True)
login_form_url = urlparse.urlunparse(url_parts)
+
+ registry = environ['paste.registry']
+ registry.register(self.request_local,
self.request_local_class(environ))
+
+ script_name = self.request_local.environ['SCRIPT_NAME']
+
+
+ login_form_url = script_name + '/' + login_form_url
+ print 'repoze', login_form_url
+
headers = [ ('Location', login_form_url) ]
headers = headers + forget_headers
return HTTPFound(headers=headers)
On May 12, 11:43 am, Chris McDonough <chr... at plope.com> wrote:
> percious wrote:
> > Ok, so I started digging, because I have to get this working for work
> > now....
> > Looking at the Tosca source:http://svn.turbogears.org/projects/ToscaWidgets/trunk/tw/mods/base.py
>
> > The "url" function:
>
> > def url(self, url):
> > """
> > Returns the absolute path for the given url.
> > """
> > prefix = self.request_local.environ['toscawidgets.prefix']
> > script_name = self.request_local.environ['SCRIPT_NAME']
> > return ''.join([script_name, prefix, url])
>
> > makes a call to a StackedObjectProxy object and pulls out the
> > 'mytg2app' from 'SCRIPT_NAME'. Is it possible to create the same
> > StackedObjectProxy in the repoze software so that the redirect does a
> > similar thing?
>
> I'm not even sure what a StackedObjectProxy is. I'm pretty sure repoze.who
> doesn't want to create one, at least in the general case.
>
> I *think* this is really just a matter of cooperating with the paste.urlmap
> middleware. You probably want to pay attention to what paste.urlmap.URLMapper
> does in its __call__ method:
>
> def __call__(self, environ, start_response):
> host = environ.get('HTTP_HOST', environ.get('SERVER_NAME')).lower()
> if ':' in host:
> host, port = host.split(':', 1)
> else:
> if environ['wsgi.url_scheme'] == 'http':
> port = '80'
> else:
> port = '443'
> path_info = environ.get('PATH_INFO')
> path_info = self.normalize_url(path_info, False)[1]
> for (domain, app_url), app in self.applications:
> if domain and domain != host and domain != host+':'+port:
> continue
> if (path_info == app_url
> or path_info.startswith(app_url + '/')):
> environ['SCRIPT_NAME'] += app_url
> environ['PATH_INFO'] = path_info[len(app_url):]
> return app(environ, start_response)
> environ['paste.urlmap_object'] = self
> return self.not_found_application(environ, start_response)
>
> E.g. it munges environ['SCRIPT_NAME'] and environ['PATH_INFO']. Joining some
> combination of those two plus the login_form_url should get you what you need, I
> think, right?
>
> - C
> _______________________________________________
> Repoze-dev mailing list
> Repoze-... at lists.repoze.orghttp://lists.repoze.org/listinfo/repoze-dev
More information about the Repoze-dev
mailing list