Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1649 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

Port tg.url() to TG2

Reported by: mramm Owned by: seanodonnell
Priority: normal Milestone:
Component: TurboGears Version: trunk
Severity: normal Keywords:
Cc:

Description

Port the tg.url function to tg2.

Attachments

url.patch Download (3.4 KB) - added by stefanha 11 years ago.

Change History

comment:1 Changed 11 years ago by mramm

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

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

comment:2 Changed 11 years ago 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?

comment:3 Changed 11 years ago 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().

comment:4 Changed 11 years ago 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'))

comment:5 Changed 11 years ago by max

commited my code in t3876, just in case.

comment:6 Changed 11 years ago by stefanha

  • Owner changed from anonymous to stefanha
  • Status changed from new to assigned

Will start by porting TG1 unit tests.

Changed 11 years ago by stefanha

comment:7 Changed 11 years ago by stefanha

  • Status changed from assigned to new
  • Owner changed from stefanha to anonymous

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.

comment:8 Changed 11 years ago by seanodonnell

  • Owner changed from anonymous to seanodonnell

comment:9 Changed 11 years ago by mramm

  • Milestone changed from 2.0 to 2.0-preview

comment:10 Changed 11 years ago 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.

comment:11 Changed 10 years ago by anonymous

  • Milestone 2.0-preview-1 deleted

Milestone 2.0-preview-1 deleted

Note: See TracTickets for help on using tickets.