On Fri, 2006-08-11 at 02:42 -0700, Tomas Jacobsen wrote:
> 
> Malcolm Tredinnick wrote:
> > On Fri, 2006-08-11 at 02:12 -0700, Tomas Jacobsen wrote:
> > > Malcolm Tredinnick wrote:
> > >
> > > The command line your talking about, is it the shell?
> >
> > Yes.
> >
> > > I've tried python manage.py shell and the code you wrote. But nothing
> > > happends when I type them in. No errors either. Do I need to replace
> > > 'portfolio/foo/blah/' with a "real" url ?
> >
> > Yes. Replace it with the sort of URL you are sending to your app.
> > Obviously the host name portion if stripped from the URL, but you
> > already have a couple of working URL patterns in that file, so you can
> > see how much to strip off the front.
> >
> > Regards,
> > Malcolm
> 
> What is suppose to happen when I write that code in? Nothing is
> happening here.

As I said in the original post, at the end of those commands, the
variable 'm' will either be None, indicating that nothing matched, or a
regular expression match object. In the latter case you can use the
Python re module's documentation (in particular,
http://docs.python.org/lib/match-objects.html ) to see what you have
captured.

> I tried to replace the 'portfolio/foo/blah/' with
> 'portfolio/web/web_project/' , but I don't see any "results" or erros
> in the shell.

In this case 'm' is None (have a look at the result of "type(m)" or "m
is None" after the final command).

The original regular expression you posted did not end with a trailing
slash, but it did require to match up to the end of the line (the final
'$'). Adding a trailing slash seems to improve things. That may well be
your only problem if those are the types of URLs you are expecting to
capture. For example, 

        >>> p = 
re.compile(r'^portfolio/(?P<category_slug>[-\w]+)/(?P<project_slug>[-\w]+)/$')
        >>> m = p.match('portfolio/web/web_project/')
        >>> m.groupdict()
        {'category_slug': 'web', 'project_slug': 'web_project'}

Best wishes,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to