1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
[straydog@saskatoon testcase]$ python2 -m pdb /usr/bin/cherryd -c cherrypy_config 
> /usr/bin/cherryd(2)<module>()
-> """The CherryPy daemon."""
(Pdb) l
  1     #!/usr/bin/python2
  2  -> """The CherryPy daemon."""
  3     
  4     import sys
  5     
  6     import cherrypy
  7     from cherrypy.process import plugins, servers
  8     from cherrypy import Application
  9     
 10     def start(configfiles=None, daemonize=False, environment=None,
 11               fastcgi=False, scgi=False, pidfile=None, imports=None):
(Pdb) l
 12         """Subscribe all engine plugins and start the engine."""
 13         sys.path = [''] + sys.path
 14         for i in imports or []:
 15             exec("import %s" % i)
 16         
 17         for c in configfiles or []:
 18             cherrypy.config.update(c)
 19             # If there's only one app mounted, merge config into it.
 20             if len(cherrypy.tree.apps) == 1:
 21                 for app in cherrypy.tree.apps.values():
 22                     if isinstance(app, Application):
(Pdb) n
> /usr/bin/cherryd(4)<module>()
-> import sys
(Pdb) n
> /usr/bin/cherryd(6)<module>()
-> import cherrypy
(Pdb) n
n
> /usr/bin/cherryd(7)<module>()
-> from cherrypy.process import plugins, servers
(Pdb) n
> /usr/bin/cherryd(8)<module>()
-> from cherrypy import Application
(Pdb) n
> /usr/bin/cherryd(10)<module>()
-> def start(configfiles=None, daemonize=False, environment=None,
(Pdb) l
  5     
  6     import cherrypy
  7     from cherrypy.process import plugins, servers
  8     from cherrypy import Application
  9     
 10  -> def start(configfiles=None, daemonize=False, environment=None,
 11               fastcgi=False, scgi=False, pidfile=None, imports=None):
 12         """Subscribe all engine plugins and start the engine."""
 13         sys.path = [''] + sys.path
 14         for i in imports or []:
 15             exec("import %s" % i)
(Pdb) l
 16         
 17         for c in configfiles or []:
 18             cherrypy.config.update(c)
 19             # If there's only one app mounted, merge config into it.
 20             if len(cherrypy.tree.apps) == 1:
 21                 for app in cherrypy.tree.apps.values():
 22                     if isinstance(app, Application):
 23                         app.merge(c)
 24         
 25         engine = cherrypy.engine
 26         
(Pdb) s
> /usr/bin/cherryd(11)<module>()
-> fastcgi=False, scgi=False, pidfile=None, imports=None):
(Pdb) s
> /usr/bin/cherryd(74)<module>()
-> if __name__ == '__main__':
(Pdb) 
> /usr/bin/cherryd(75)<module>()
-> from optparse import OptionParser
(Pdb) l
 70         else:
 71             engine.block()
 72     
 73     
 74     if __name__ == '__main__':
 75  ->     from optparse import OptionParser
 76         
 77         p = OptionParser()
 78         p.add_option('-c', '--config', action="append", dest='config',
 79                      help="specify config file(s)")
 80         p.add_option('-d', action="store_true", dest='daemonize',
(Pdb) l
 81                      help="run the server as a daemon")
 82         p.add_option('-e', '--environment', dest='environment', default=None,
 83                      help="apply the given config environment")
 84         p.add_option('-f', action="store_true", dest='fastcgi',
 85                      help="start a fastcgi server instead of the default HTTP server")
 86         p.add_option('-s', action="store_true", dest='scgi',
 87                      help="start a scgi server instead of the default HTTP server")
 88         p.add_option('-i', '--import', action="append", dest='imports',
 89                      help="specify modules to import")
 90         p.add_option('-p', '--pidfile', dest='pidfile', default=None,
 91                      help="store the process id in the given file")
(Pdb) l
 92         p.add_option('-P', '--Path', action="append", dest='Path',
 93                      help="add the given paths to sys.path")
 94         options, args = p.parse_args()
 95         
 96         if options.Path:
 97             for p in options.Path:
 98                 sys.path.insert(0, p)
 99         
100         start(options.config, options.daemonize,
101               options.environment, options.fastcgi, options.scgi, options.pidfile,
102               options.imports)
(Pdb) l
103     
[EOF]
(Pdb) n
> /usr/bin/cherryd(77)<module>()
-> p = OptionParser()
(Pdb) n
> /usr/bin/cherryd(78)<module>()
-> p.add_option('-c', '--config', action="append", dest='config',
(Pdb) n
> /usr/bin/cherryd(79)<module>()
-> help="specify config file(s)")
(Pdb) n
> /usr/bin/cherryd(80)<module>()
-> p.add_option('-d', action="store_true", dest='daemonize',
(Pdb) n
> /usr/bin/cherryd(81)<module>()
-> help="run the server as a daemon")
(Pdb) n
> /usr/bin/cherryd(82)<module>()
-> p.add_option('-e', '--environment', dest='environment', default=None,
(Pdb) n
> /usr/bin/cherryd(83)<module>()
-> help="apply the given config environment")
(Pdb) n
> /usr/bin/cherryd(84)<module>()
-> p.add_option('-f', action="store_true", dest='fastcgi',
(Pdb) n
> /usr/bin/cherryd(85)<module>()
-> help="start a fastcgi server instead of the default HTTP server")
(Pdb) n
> /usr/bin/cherryd(86)<module>()
-> p.add_option('-s', action="store_true", dest='scgi',
(Pdb) n
> /usr/bin/cherryd(87)<module>()
-> help="start a scgi server instead of the default HTTP server")
(Pdb) n
> /usr/bin/cherryd(88)<module>()
-> p.add_option('-i', '--import', action="append", dest='imports',
(Pdb) n
> /usr/bin/cherryd(89)<module>()
-> help="specify modules to import")
(Pdb) n
> /usr/bin/cherryd(90)<module>()
-> p.add_option('-p', '--pidfile', dest='pidfile', default=None,
(Pdb) n
> /usr/bin/cherryd(91)<module>()
-> help="store the process id in the given file")
(Pdb) l
 86         p.add_option('-s', action="store_true", dest='scgi',
 87                      help="start a scgi server instead of the default HTTP server")
 88         p.add_option('-i', '--import', action="append", dest='imports',
 89                      help="specify modules to import")
 90         p.add_option('-p', '--pidfile', dest='pidfile', default=None,
 91  ->                  help="store the process id in the given file")
 92         p.add_option('-P', '--Path', action="append", dest='Path',
 93                      help="add the given paths to sys.path")
 94         options, args = p.parse_args()
 95         
 96         if options.Path:
(Pdb) l
 97             for p in options.Path:
 98                 sys.path.insert(0, p)
 99         
100         start(options.config, options.daemonize,
101               options.environment, options.fastcgi, options.scgi, options.pidfile,
102               options.imports)
103     
[EOF]
(Pdb) n
> /usr/bin/cherryd(92)<module>()
-> p.add_option('-P', '--Path', action="append", dest='Path',
(Pdb) n
> /usr/bin/cherryd(93)<module>()
-> help="add the given paths to sys.path")
(Pdb) n
> /usr/bin/cherryd(94)<module>()
-> options, args = p.parse_args()
(Pdb) n
> /usr/bin/cherryd(96)<module>()
-> if options.Path:
(Pdb) n
> /usr/bin/cherryd(100)<module>()
-> start(options.config, options.daemonize,
(Pdb) s
> /usr/bin/cherryd(101)<module>()
-> options.environment, options.fastcgi, options.scgi, options.pidfile,
(Pdb) s
> /usr/bin/cherryd(102)<module>()
-> options.imports)
(Pdb) s
--Call--
> /usr/bin/cherryd(10)start()
-> def start(configfiles=None, daemonize=False, environment=None,
(Pdb) s
> /usr/bin/cherryd(13)start()
-> sys.path = [''] + sys.path
(Pdb) l
  8     from cherrypy import Application
  9     
 10     def start(configfiles=None, daemonize=False, environment=None,
 11               fastcgi=False, scgi=False, pidfile=None, imports=None):
 12         """Subscribe all engine plugins and start the engine."""
 13  ->     sys.path = [''] + sys.path
 14         for i in imports or []:
 15             exec("import %s" % i)
 16         
 17         for c in configfiles or []:
 18             cherrypy.config.update(c)
(Pdb) l
 19             # If there's only one app mounted, merge config into it.
 20             if len(cherrypy.tree.apps) == 1:
 21                 for app in cherrypy.tree.apps.values():
 22                     if isinstance(app, Application):
 23                         app.merge(c)
 24         
 25         engine = cherrypy.engine
 26         
 27         if environment is not None:
 28             cherrypy.config.update({'environment': environment})
 29         
(Pdb) l
 30         # Only daemonize if asked to.
 31         if daemonize:
 32             # Don't print anything to stdout/sterr.
 33             cherrypy.config.update({'log.screen': False})
 34             plugins.Daemonizer(engine).subscribe()
 35         
 36         if pidfile:
 37             plugins.PIDFile(engine, pidfile).subscribe()
 38         
 39         if hasattr(engine, "signal_handler"):
 40             engine.signal_handler.subscribe()
(Pdb) s
> /usr/bin/cherryd(14)start()
-> for i in imports or []:
(Pdb) l
  9     
 10     def start(configfiles=None, daemonize=False, environment=None,
 11               fastcgi=False, scgi=False, pidfile=None, imports=None):
 12         """Subscribe all engine plugins and start the engine."""
 13         sys.path = [''] + sys.path
 14  ->     for i in imports or []:
 15             exec("import %s" % i)
 16         
 17         for c in configfiles or []:
 18             cherrypy.config.update(c)
 19             # If there's only one app mounted, merge config into it.
(Pdb) s
> /usr/bin/cherryd(17)start()
-> for c in configfiles or []:
(Pdb) l
 12         """Subscribe all engine plugins and start the engine."""
 13         sys.path = [''] + sys.path
 14         for i in imports or []:
 15             exec("import %s" % i)
 16         
 17  ->     for c in configfiles or []:
 18             cherrypy.config.update(c)
 19             # If there's only one app mounted, merge config into it.
 20             if len(cherrypy.tree.apps) == 1:
 21                 for app in cherrypy.tree.apps.values():
 22                     if isinstance(app, Application):
(Pdb) s
> /usr/bin/cherryd(18)start()
-> cherrypy.config.update(c)
(Pdb) l
 13         sys.path = [''] + sys.path
 14         for i in imports or []:
 15             exec("import %s" % i)
 16         
 17         for c in configfiles or []:
 18  ->         cherrypy.config.update(c)
 19             # If there's only one app mounted, merge config into it.
 20             if len(cherrypy.tree.apps) == 1:
 21                 for app in cherrypy.tree.apps.values():
 22                     if isinstance(app, Application):
 23                         app.merge(c)
(Pdb) s
--Call--
> /usr/lib/python2.7/site-packages/cherrypy/_cpconfig.py(155)update()
-> def update(self, config):
(Pdb) l
150     
151     
152     class Config(reprconf.Config):
153         """The 'global' configuration data for the entire CherryPy process."""
154     
155  ->     def update(self, config):
156             """Update self from a dict, file or filename."""
157             if isinstance(config, basestring):
158                 # Filename
159                 cherrypy.engine.autoreload.files.add(config)
160             reprconf.Config.update(self, config)
(Pdb) l
161     
162         def _apply(self, config):
163             """Update self from a dict."""
164             if isinstance(config.get("global", None), dict):
165                 if len(config) > 1:
166                     cherrypy.checker.global_config_contained_paths = True
167                 config = config["global"]
168             if 'tools.staticdir.dir' in config:
169                 config['tools.staticdir.section'] = "global"
170             reprconf.Config._apply(self, config)
171         
(Pdb) n
> /usr/lib/python2.7/site-packages/cherrypy/_cpconfig.py(157)update()
-> if isinstance(config, basestring):
(Pdb) n
> /usr/lib/python2.7/site-packages/cherrypy/_cpconfig.py(159)update()
-> cherrypy.engine.autoreload.files.add(config)
(Pdb) n
> /usr/lib/python2.7/site-packages/cherrypy/_cpconfig.py(160)update()
-> reprconf.Config.update(self, config)
(Pdb) n
<problem.Problem object at 0xa14424c>
[30/Dec/2011:11:16:33] ENGINE Mounted: cherrypy._cptree.Application(<problem.Problem object at 0xa14424c>, '') on /
--Return--
> /usr/lib/python2.7/site-packages/cherrypy/_cpconfig.py(160)update()->None
-> reprconf.Config.update(self, config)
(Pdb) n
> /usr/bin/cherryd(20)start()
-> if len(cherrypy.tree.apps) == 1:
(Pdb) n
> /usr/bin/cherryd(21)start()
-> for app in cherrypy.tree.apps.values():
(Pdb) n
> /usr/bin/cherryd(22)start()
-> if isinstance(app, Application):
(Pdb) n
> /usr/bin/cherryd(23)start()
-> app.merge(c)
(Pdb) n
<problem.Problem object at 0xa1ad76c>
> /usr/bin/cherryd(21)start()
-> for app in cherrypy.tree.apps.values():
(Pdb) l
 16         
 17         for c in configfiles or []:
 18             cherrypy.config.update(c)
 19             # If there's only one app mounted, merge config into it.
 20             if len(cherrypy.tree.apps) == 1:
 21  ->             for app in cherrypy.tree.apps.values():
 22                     if isinstance(app, Application):
 23                         app.merge(c)
 24         
 25         engine = cherrypy.engine
 26         
(Pdb) l
 27         if environment is not None:
 28             cherrypy.config.update({'environment': environment})
 29         
 30         # Only daemonize if asked to.
 31         if daemonize:
 32             # Don't print anything to stdout/sterr.
 33             cherrypy.config.update({'log.screen': False})
 34             plugins.Daemonizer(engine).subscribe()
 35         
 36         if pidfile:
 37             plugins.PIDFile(engine, pidfile).subscribe()
(Pdb)