On Dec 17, 2009, at 10:48 AM, Jay wrote:

> The file is named 0_redefine_url.py and is in my applications/init/
> models folder.  It contains:

Massimo may know what's going on, but the new URL() isn't getting called. In 
the meantime, how about trying this to make an https URL; seems simpler:


def SURL(*a, **b):
    return 'https://' + request.env.http_host + URL(*a,**b)

> 
> _URL=URL
> def URL(*a,**b):
>   if not 'secure' in b:
>       return _URL(*a,**b)
>   elif b['secure']:
>       del b['secure']
>       return 'https://'+request.env.http_host + _URL(*a,**b)
>   else:
>       del b['secure']
>       return 'http://'+request.env.http_host + _URL(*a,**b)
> 
> Here is the complete traceback:
> Error traceback
> 
> Traceback (most recent call last):
>  File "/home/jayr/workspace/newsite/app/gluon/restricted.py", line
> 178, in restricted
>    exec ccode in environment
>  File "/home/jayr/workspace/newsite/app/applications/init/controllers/
> profile.py", line 248, in <module>
>  File "/home/jayr/workspace/newsite/app/gluon/globals.py", line 102,
> in <lambda>
>    self._caller = lambda f: f()
>  File "/home/jayr/workspace/newsite/app/gluon/tools.py", line 1418,
> in f
>    return action(*a, **b)
>  File "/home/jayr/workspace/newsite/app/applications/init/controllers/
> profile.py", line 199, in notes
>    print_notes = URL(r=request, a=request.application, c='profile',
> f='notes_print', secure='True')
> TypeError: URL() got an unexpected keyword argument 'secure'
> 
> Thanks,
> 
> - Jay
> 
> On Dec 17, 10:58 am, Jonathan Lundell <jlund...@pobox.com> wrote:
>> On Dec 17, 2009, at 6:38 AM, Jay wrote:
>> 
>>> I cant seem to make this work.  I created the file in models
>>> and modified a url helper to use it and received the following error:
>> 
>>> TypeError: URL() got an unexpected keyword argument 'secure'
>> 
>> It might help to see the entire traceback.
>> 
>> 
>> 
>>> A few follow up questions:
>>> 1.  Did you intend to say 'model' rather than module?
>> 
>> 'models'
>> 
>>> 2.  How do I integrate 0_redefine_url.py into my app such that the
>>> URL
>>> helper will accept the keyword argument 'secure'?
>> 
>> The idea is to stick it in applications/yourapp/models/, which makes it 
>> visible to the entire app. The prepended '0' makes it sort to the beginning, 
>> so it's also available to the other model files.
>> 
>> 
>> 
>> 
>> 
>>> Thanks
>> 
>>> - Jay
>> 
>>> On Dec 17, 1:20 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>>>> I do not think it is a idea because would encourage people to use it
>>>> and build non-portable applications.
>>>> If users were doing that, the applications may break when running on
>>>> port 8000 or would break when being a proxy if it where to detect the
>>>> port. There is no definitive way for the app to know the public URL.
>> 
>>>> Moreover it would only form when called with URL(r=request,...) but
>>>> not when called with URL(app,...) because it would have no knowledge
>>>> of the request object.
>> 
>>>> I think whether to use https and/or https should be handled outside
>>>> the application.
>> 
>>>> Massimo
>> 
>>>> On Dec 16, 10:52 pm, Jonathan Lundell <jlund...@pobox.com> wrote:
>> 
>>>>> On Dec 16, 2009, at 6:58 PM, Álvaro Justen [Turicas] wrote:
>> 
>>>>>> On Thu, Dec 10, 2009 at 20:50, mdipierro <mdipie...@cs.depaul.edu> wrote:
>>>>>>> I would suggest creating a model 0_redefine_url.py that contains:
>> 
>>>>>>> _URL=URL
>>>>>>> def URL(*a,**b):
>>>>>>>   if not 'secure' in b:
>>>>>>>       return _URL(*a,**b)
>>>>>>>   elif b['secure']:
>>>>>>>       del b['secure']
>>>>>>>       return 'https://'+request.env.http_host + _URL(*a,**b)
>>>>>>>   else:
>>>>>>>       del b['secure']
>>>>>>>       return 'http://'+request.env.http_host + _URL(*a,**b)
>> 
>>>>>>> and use URL(....,secure=True), URL(...secure=False) as required
>> 
>>>>>> I think this is very useful. Can we add this in trunk?
>> 
>>>>> It *would* be useful, I think. If URL() defaults secure=None ...
>> 
>>>>>>> Massimo
>> 
>>>>>>> 'https://'+request.env.http_host +'/app/default/logon')
>> 
>>>>>>> On Dec 10, 2:11 pm, Wes James <compte...@gmail.com> wrote:
>>>>>>>> Actually, I don't think it would matter if there were a proxy or not??
>> 
>>>>>>>> On Thu, Dec 10, 2009 at 1:06 PM, Wes James <compte...@gmail.com> wrote:
>>>>>>>>> As long as you don't have a proxy between your users and the server
>>>>>>>>> something with request.env could be used
>> 
>>>>>>>>> def login():
>>>>>>>>>    if request.env.port != 443:
>>>>>>>>>       redirect('https://'+request.env.http_host +'/app/default/logon')
>> 
>>>>>>>>> -wes
>> 
>>>>>>>>> On Thu, Dec 10, 2009 at 11:42 AM, Jay <j...@unclehenrys.com> wrote:
>>>>>>>>>>  I am new to web2py and Apache w/mod_ssl and I have been searching
>>>>>>>>>> for
>>>>>>>>>>  a solution related to this topic but I must be missing a basic
>>>>>>>>>>  understanding of the necessary pieces in order to accomplish this.
>> 
>>>>>>>>>>  Our web2py apache setup seems to be fine.  I can access our app's
>>>>>>>>>>  pages using both http and https if I manually add the 's' to the 
>>>>>>>>>> url.
>> 
>>>>>>>>>>  What we are trying to do is smoothly transition from one controller/
>>>>>>>>>>  function using http to another using https.
>>>>>>>>>>  Example, a user arrives athttp://init/default/indexandthenthe
>>>>>>>>>> user
>>>>>>>>>>  selects ‘Login’ and they are sent to https:/init/default/login.  We
>>>>>>>>>>  need some controller functions to use http and some https.  Can this
>>>>>>>>>>  be done from within the controller/function?  If not, what is the
>>>>>>>>>>  ‘best practice’ approach to accomplishing this?
>> 
>>>>>>>>>>  - Jay


--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to