Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
fixing raven issues, too much data gets cut, switch to extra, skip pp…
Browse files Browse the repository at this point in the history
…rint
  • Loading branch information
agroszer committed Jun 20, 2016
1 parent 5d30d83 commit 0e92f44
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/cipher/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""Session handling
"""
import logging
import pprint

import zope.interface
import zope.component
Expand All @@ -35,12 +34,10 @@
LOG = logging.getLogger('cipher.session.session')


def formatData(inData):
log_rows = []
for name, data in sorted(inData.items()):
log_rows.append(name)
log_rows.append(pprint.pformat(data))
return log_rows
def formatExtraData(extra, **inData):
for name, data in inData.items():
extra[name] = repr(data)
return extra


class AppendOnlyDict(PersistentMapping):
Expand Down Expand Up @@ -81,8 +78,8 @@ def _p_resolveConflict(self, old, committed, new):
raise ConflictError("Can't resolve 'clear'")

# save old state, messing with result_data overwrite state
log_rows = ["Conflicting insert"]
log_rows.extend(formatData(dict(old=old, committed=committed, new=new)))
extra = {}
formatExtraData(extra, old=old, committed=committed, new=new)

result = old.copy()
c_new = {}
Expand All @@ -103,9 +100,8 @@ def _p_resolveConflict(self, old, committed, new):
neq = True
if neq:
# log everything, debugging ConflictResolution is hard
log_rows.extend(
formatData(dict(k=k, v=v, c_new=c_new, result=result)))
LOG.exception('\n----\n'.join(log_rows))
formatExtraData(extra, k=k, v=v, c_new=c_new, result=result)
LOG.exception("Conflicting insert", extra=extra)
raise ConflictError("Conflicting insert")
if k in result_data:
continue
Expand All @@ -120,11 +116,10 @@ class SessionData(data.SessionData):
# parts/inspiration taken from repoze.session

def _internalResolveConflict(self, resolved, old, committed, new):
log_rows = ["Competing writes to session data:"]
log_rows.extend(formatData(dict(old=old, committed=committed, new=new)))
msg = "\n----\n".join(log_rows)
LOG.exception(msg)
raise ConflictError(msg)
extra = {}
formatExtraData(extra, old=old, committed=committed, new=new)
LOG.exception("Competing writes to session data:", extra=extra)
raise ConflictError("Competing writes to session data:")

def _p_resolveConflict(self, old, committed, new):
# dict modifiers set '_lm'.
Expand Down

0 comments on commit 0e92f44

Please sign in to comment.