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

Suggestion: Session panel #313

Open
jvanasco opened this issue May 31, 2017 · 2 comments
Open

Suggestion: Session panel #313

jvanasco opened this issue May 31, 2017 · 2 comments

Comments

@jvanasco
Copy link
Contributor

I wrote a custom variation of this idea and wanted to suggest it upstream after seeing the 4.1 announcement

We split sessions into a separate panel so that the data can be captured BEFORE and AFTER the request is processed, then show the info side-by-side on a table. I forget where the toolbar currently captures data, but it's only one.

@mmerickel
Copy link
Member

Right now we snapshot the session upon first access. Tracking its updated state and visualizing the changes sounds nice.

@jvanasco
Copy link
Contributor Author

jvanasco commented Jun 8, 2017

It's a lifesaver. We don't use Pyramid's stock sessions, so my panel is incompatible as-is. I don't know when I'll have time to port, but will try to.

If anyone wants to tackle it before I get to this, this is generally what we have running:

in our panel sessions.py:

class SessionDebugPanel(DebugPanel):

    # we need the request in the response phase
    __request = None

    def __init__(self, request):
        self.__request = request  # stash for response
        self.data = data = {'session_request': None,
                            'session_response': None,
                            }
        _request_attrs = request.__dict__.copy()
        if 'session' in _request_attrs:
            data.update({'session_request': _request_attrs['session']}
        
    def process_response(self, response):
        _request_attrs = self.__request.__dict__.copy()
        if 'session' in _request_attrs:
            data.update({'session_response': _request_attrs['session']}

the display html just creates a table of all the keys present in both, then iterates them as:

<tr><th>key</th>
       <td>request</td>
       <td>response</td>
       </tr>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants