Ticket #1649 (closed defect: fixed)

Opened 11 months ago

Last modified 10 months ago

Port tg.url() to TG2

Reported by: mramm Assigned to: seanodonnell
Priority: normal Milestone: 2.0-preview-1
Component: TurboGears Version: trunk
Severity: normal Keywords:
Cc:

Description

Port the tg.url function to tg2.

Attachments

url.patch (3.4 kB) - added by stefanha on 01/12/08 11:56:34.

Change History

01/04/08 22:11:29 changed by mramm

Port the tg.url function to tg2. The origonal can be found at:

source:/branches/1.0/turbogears/controllers.py line 477

01/12/08 04:22:43 changed by max

  • owner changed from anonymous to max.
  • status changed from new to assigned.

I guess new impl. should be using WebOb?, http://pythonpaste.org/webob/#urls?

01/12/08 05:22:12 changed by max

got stuck. I'm writing a unit test and I need a way to setup pylons.request so that I can test the url().

01/12/08 06:34:48 changed by max

  • owner changed from max to anonymous.
  • status changed from assigned to new.

give up.

I implemented a create_request() function so that url() can tested easily. But it seems to me that re-writing it to work with newer webob yet be compatible with TG1 would take too much time. And it's not clear whether its worth it. I move on to other things, feel free to pick the ticket up.

P.S.: My "naive" code looked like this:

def url(tgpath, tgparams=None, **kw):
    from tg import request
    if not isinstance(tgpath, basestring):
        tgpath = "/".join(list(tgpath))
    path = request.relative_url(tgpath)
    base_url = request.path_url
    return path[len(base_url):]

def test_url():
    create_request('/')
    eq_('hello', url('hello'))
    eq_('/hello', url('/hello'))

01/12/08 06:40:33 changed by max

commited my code in t3876, just in case.

01/12/08 09:24:10 changed by stefanha

  • owner changed from anonymous to stefanha.
  • status changed from new to assigned.

Will start by porting TG1 unit tests.

01/12/08 11:56:34 changed by stefanha

  • attachment url.patch added.

01/12/08 11:57:17 changed by stefanha

  • owner changed from stefanha to anonymous.
  • status changed from assigned to new.

Giving up, too. Looking at url() in TG1, redirect() could share code with url().

I have attached a patch against rev 3887. It contains incomplete work, including unit tests ported from TG1.

01/12/08 17:09:46 changed by seanodonnell

  • owner changed from anonymous to seanodonnell.

01/13/08 08:13:28 changed by mramm

  • milestone changed from 2.0 to 2.0-preview.

01/13/08 11:35:35 changed by mramm

  • status changed from new to closed.
  • resolution set to fixed.

The TG portion of this is fixed, waiting on some changes in webob.