~james-w/python-oops/update-readme-dependencies

« back to all changes in this revision

Viewing changes to README

  • Committer: Robert Collins
  • Date: 2011-08-16 06:12:49 UTC
  • Revision ID: robertc@robertcollins.net-20110816061249-nh1oxqmbna9jd0bf
Permit a context to be provided to on creation hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
  >>> from oops import Config
55
55
  >>> config = Config()
56
56
 
57
 
* New report will be based on the template::
 
57
* New reports will be based on the template report::
58
58
 
59
59
  >>> config.template
60
60
  {}
68
68
when the oops is created, or to override / tweak the information gathered by an
69
69
earlier callback)::
70
70
 
71
 
  >>> mycallback = lambda report: None
 
71
  >>> mycallback = lambda report, context: None
72
72
  >>> config.on_create.append(mycallback)
73
73
 
 
74
The context parameter is also just dict, and is passed to all the on_create
 
75
callbacks similarly to the report. This is used to support passing information
 
76
to the on_create hooks. For instance, the exc_info key is used to pass in
 
77
information about the exception being logged (if one was caught).
 
78
 
74
79
* Later on, when something has gone wrong and you want to create an OOPS
75
80
report::
76
81
 
77
 
  >>> report = config.create()
 
82
  >>> report = config.create(context=dict(exc_info=sys.exc_info()))
78
83
  >>> report
79
84
  {'appname': 'demo', 'branch_nick': 'mybranch'}
80
85
 
88
93
to the repository). Publishers should try to use report['id'] for the id, if it
89
94
is set. This is automatically set to the id returned by the previous publisher.
90
95
 
 
96
If publish returns None, then the report was filtered (see the api docs for
 
97
more information).
 
98
 
91
99
  >>> 'id' in report
92
100
  False
93
101
  >>> def demo_publish(report):
98
106
  >>> report['id']
99
107
  'id 1'
100
108
 
101
 
* The oops_datedir_repo package contains a local disk based repository which
 
109
* The related project oops_datedir_repo contains a local disk based repository which
102
110
can be used as a publisher.
103
111
 
104
112
More coming soon.