The 'urlbase' definition in the code is supposed to be everything in
the url up to the first occurrence of "?" or "/". So if you have
"/feeds/pics/user1/stuff.php?foo=bar", the code should actually call,
simply, "feeds" the urlbase. That was the plan at the outset, but I'll
freely admit to not thinking deeply about this feature until now (and
I still haven't had time to give it due diligence). I did a quick
test, and it appears to me that the regex is not working properly,
because it's matching parts of a request beyond the first occurrence
of "/" (though "?" seems to work ok).
Regardless, what you really want (and I think would be nice too) is
not the urlbase, but to filter the lines based on what the code would
consider arbitrary substring components of the request :-)
I'll poke at this more in my late night coding sessions during this
week. Hopefully I can get a fix in place in the next couple of days.
brian.
--
Brian K. Jones
Python Magazine http://www.pythonmagazine.com
My Blog http://www.protocolostomy.com
Looking at the code, it seems that urlbase is the path and base is
supposed to be the first path component.
I suggest using the terminology from urlparse() for the components it
creates.
> Instead if we were to say that the urlbase is part of the url that
> does not include the query parameters
> its pretty clear what it mean IMHO. What say you ?
Yes, that is the path.
>
>> That was the plan at the outset, but I'll
>> freely admit to not thinking deeply about this feature until now (and
>> I still haven't had time to give it due diligence). I did a quick
>> test, and it appears to me that the regex is not working properly,
>> because it's matching parts of a request beyond the first occurrence
>> of "/" (though "?" seems to work ok).
Regexes are greedy. You have "^\/.*[\?\/]" which will match to the
*last* /. You could use r"^\/[^\?\/]*" to match to the first ? or /.
I don't think you will actually see a ? in the path returned from
urlparse() though.
Some unit tests would help here, both to clearly express your intent and
to make sure you have correctly implemented it.
> The way I have implemented it in my local code base now is by using
> the
> python 'in' operator, which is really easy to implement if we apply
> the changes to filter
> I mentioned in my last email. What you would do is set the rules cmp
> attribute to the 'in' operator
> and in the __call__ method of the rule you have the 'in' case do the
> following
>
> def __call__(self,line):
> #print line.__dict__[self.attr]+self.cmp+ self.val
> if self.cmp == "==":
> return (line.__dict__[self.attr] == self.val)
> elif self.cmp == "in":
> return (self.val in line.__dict__[self.attr])
>
> Hence now you have substring comparisons :).
'in' is useful, a regex search might be useful as well.
How do you express this in the command-line parameters?
Kent