reverse url resolution not working.

0 views
Skip to first unread message

redazzo

unread,
Oct 23, 2007, 6:02:48 AM10/23/07
to Satchmo users
Hi,

I seriously hope someone can help me here, as I'm at my wits end.

I'm trying to move to Satchmo version 0.5. Unfortunately, the django
url resolution mechanism is not working when attempting to do a
'reverse lookup'.

For example, in the satcho.product.models module, the product class
defines the following

def get_absolute_url(self):
return urlresolvers.reverse('satchmo_product',
kwargs={'product_slug': self.slug})

Now, in my template I have the following:

<td><h3 style="font-size: 13pt;"><a
href="{{ product.get_absolute_url }}">{{ product.name }}</a></h3></td>

Unfortunately, when get_absolute_url is called, it seems to be
silently failing and returning an empty string.

This was working fine before the attempted upgrade.

In my attempts to track it down, I've reverted everything, ensured the
application was working, and gone through the merge process again -
only to discover the exact same problem.

This has caused great frustration, as I need to move to release 0.5
for a number of the bug fixes in that version.

Has anyone else come up against the same problem?

btw I'm running against django 5947.

Cheers,
G

Chris Moffitt

unread,
Oct 23, 2007, 9:04:35 AM10/23/07
to satchm...@googlegroups.com
Sometimes when developing on Satchmo and I made an error in a config file or one of the urls files, I found that an error could cause this exact sort of behavior.  It's difficult to track down but I think it's more of a django issue than Satchmo.  That being said, I seem to recall that there was a recent checkin on Django that attempted to provide a more verbose error message for url import problems.

If you have a fresh version of 0.5, does it work?  If so, you might want to start with that and gradually incorporate the changes.
-Chris

Bruce Kroeze

unread,
Oct 23, 2007, 11:10:57 AM10/23/07
to satchm...@googlegroups.com
What I do to resolve such issues is something like this:

$ ./manage.py shell

Python >> from django.core import urlresolvers
>> urlresolvers.reverse('satchmo_product', None, {'product_slug' : 'foo'})

You should get a more helpful exception here.

----

This works because templates will silently ignore resolution errors, unlike direct interpreter commands.

- Bruce Kroeze


redazzo

unread,
Oct 26, 2007, 11:54:08 PM10/26/07
to Satchmo users
Bruce,

Thanks for the hint - I did exactly what you suggested and managed to
track it down. Using the shell, I managed to work out where the
exception was being thrown.

Interestingly, the bug was in a completely different area of the code
(i.e. it wasn't remotely template-related); invocation of the template
was causing a module to be loaded, which was in turn loading *another*
module that was throwing an exception when Satchmo tried to initialize
it (a new payments module I've written to allow Satchmo to deal with a
NZ credit-card payment gateway provider). This last module had some
initialization methods with signatures that had changed on the move to
version 0.5.

Its certainly been one of the more difficult bugs I've had to track
down recently.

Cheers!
G

Reply all
Reply to author
Forward
0 new messages