On Wed, Dec 16, 2009 at 8:45 PM, Bruce Kroeze <[email protected]> wrote:
> On Wed, Dec 16, 2009 at 9:32 AM, Joseph Wayodi <[email protected]> wrote: > >> I've put my signal-registration code in my app's models.py, and my app is >> the last one in the INSTALLED_APPS setting. >> > > It shouldn't matter where in the list your app is placed. > > >> I've done a bit of testing, and it appears that by the time I register my >> listener function to receive the signal, it has already been sent, and I'm >> therefore too late. It also appears that products.urls (from where the >> signal is sent) is loaded in parallel with my app's models.py. I've tried >> writing to standard output from different places in my models.py, and it >> appears that I can catch the signal by going towards the top of the file. >> > > That seems odd. Are you doing some sort of url reversing in your models? > Usually, the urls aren't resolved in a Django app until the first time > something needs to be looked up. If you are using urlresolvers.reverse, > that would cause the urls to get loaded. > > >> Am I wrong about how Satchmo and signals work? >> > > No, that's the way it is normally used. There are a ton of examples in > Satchmo, as it is the main way we add urls for optional apps. > > >> I'm trying to use that signal to add a URL to /$SHOP_BASE/$PRODUCT_SLUG/ >> without hard coding it too much. Is the signal meant for such stuff in the >> first place? Or should I try something else? >> > > You could probably just use the SHOP_URLS setting in your settings.py file, > and skip the signal altogether. > > -- > Bruce Kroeze > http://www.ecomsmith.com > It's time to hammer your site into shape. > > -- > You received this message because you are subscribed to the Google Groups > "Satchmo users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<satchmo-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/satchmo-users?hl=en. > Thanks for your quick response. I found the problem, using your tip that urlresolvers.reverse must have been called from within my models module. I wanted to modify the urlpatterns being sent in the signal, so I'd thought that the best place to put the listener function would be in my app's urls.py. But the urls.py imports satchmo_store.urls.urlpatterns, which causes Satchmo to send the collect_urls signals. So I've moved my listener function to a different module for now, and the signal now only gets sent when I access the the shop via the browser. I'll now try and do the actuall modification of the urlpatterns. Thanks a lot! Joseph Wayodi. -- You received this message because you are subscribed to the Google Groups "Satchmo users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.
