On Sun, Dec 14, 2008 at 10:15 PM, Stefan Behnel <stefan_ml@behnel.de> wrote:
Hi,

Olivier Lauzanne wrote:
> I have implemented some of the classes that are present in jQuery but not in
> the css standard. Extending the classes seems like the right way to do it.
> You can check it out here.
>
> http://www.bitbucket.org/olauzanne/pyquery/src/tip/pyquery/cssselectpatch.py
>
> cssselect should remain standard compliant but I could make a patch so that
> using the jQuery pseudo classes is an option of the CSSSelector class. I
> don't have a strong opinion about doing it or not doing it. What do you
> think ?

Would it make sense to make this a separate module like "jqselect" (which
would inherit most of the API of cssselect) instead of patching into
cssselect itself?

Stefan

It's possible but not simple. I would have to add a parameter on most functions down to parse_simple_selector for it to use some specific Pseudo and Function classes. Or else I would have to do some major refactoring : putting most functions in a class and using self.Pseudo and self.Function instead of Pseudo and Function. That would be the nicest I think.

Then the JQueryPseudo and JQueryFunction classes could be put in a different file.

Anyway I have to patch cssselect if I don't want to duplicate code (which I don't want), either with a monkey patch or by modifying cssselect. The most simple is definitly monkey patching. But it's not the safest in the long term.

Olivier