-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeat less in toolset declarations #28
Comments
I would be glad not to have to copy/paste again and again those function names :-) I'm not so familiar with how to deal with locals(). Can you suggest some code to do this, please? While we are speaking about the postprocessors ( |
I assigned it to myself, but you can grab it if it saves you work. Basically, def toolset():
|
So simple! Thanks! I can take this issue since I'm currently working on the concerned files. What about a class structure for the postprocessors? |
I like the idea of putting the toolset function in a class rather than in a dict. It's little less weird, and, as you say, it lets us use inheritance (though there isn't much shared functionality right now). We can put a |
I have been trying to implement toolsets as classes for 2 days with no success. My problem is that the functions of the toolsets are really used as "global" functions. To put them in a class, I see 3 options:
Finally, what we want is having something simple and easily define the allowed_tags and allowed_entities in the postprocessors. Maybe the current state of the code is enough for that. I will keep the class idea in mind in case I find a more efficient solution that what I tried; of course, please don't hesitate to suggest another approach, I'd be happy to try it! |
Your first alternative is the right one; the piece you're missing is to pass not SomeToolset.function but rather SomeToolset().function, so that function is bound to an instance and automatically gets the |
Maybe stick [references to] the toolset functions within an outer function and return locals() from it, rather than writing out a big dict like peter17@19d8ad3#L0L26.
The text was updated successfully, but these errors were encountered: