Skip to content
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

plominoutils_tool branch #107

Open
jean opened this issue Apr 24, 2012 · 2 comments
Open

plominoutils_tool branch #107

jean opened this issue Apr 24, 2012 · 2 comments
Labels

Comments

@jean
Copy link
Member

jean commented Apr 24, 2012

In order to allow utility methods to access context, they need to live on a persistent tool.

The version of PlominoUtils on the https://github.com/plomino/Plomino/tree/plominoutils_tool branch requires that.

From Eric:
compileFormulaScript would get the tool, so instead of inserting:

from PlominoUtils import DateToString, htmlencode, ...

it would do:

utils_tools = getToolByName('the_tool'); DateToString = utis_tools.DateToString

Note that after this change, existing formulas would need to be recompiled (deleted from scripts). This could be done in a migration step.

@ebrehault
Copy link
Member

there is also anoher approach: we keep PlominoUtils functions, and we just add a new one like that:

from zope.globalrequest import getRequest

def findContext():
    """Find the context
    """
    request = getRequest()
    published = request.get('PUBLISHED', None)
    context = getattr(published, '__parent__', None)
    if context is None:
        context = request.PARENTS[0]
    return context

(I saw that as I was trying to solve a bug in plone.app.theming, I didn't knew the getRequest method, maybe it could be helpful with PlominoAgent.run_async)

@jean
Copy link
Member Author

jean commented Apr 26, 2012

This looks like a better approach for utils.

It doesn't look like it would work for async:

> .../Products/CMFPlomino/PlominoAgent.py(121)runAgent()
-> plominoContext = self
(Pdb) getattr(self, 'REQUEST', None) is None
True
(Pdb) from zope.globalrequest import getRequest
(Pdb) getRequest() is None
True

djay pushed a commit that referenced this issue Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants