Troubleshooting Plone Ricardo Alves [email_address] Plone Conference 2009 - Budapest
What can go wrong?
Main Issues <ul><li>Site errors and broken objects
Instance not responding
Server IO errors
Unauthorized / security errors </li></ul>
Site Errors <ul><li>Analyzing the traceback at error_log:
http://mysite/plonesite/error_log/manage_main </li></ul>
 
 
Site Errors <ul><li>Analyzing Zope's event log:
INSTANCE_HOME/logs/event.log </li></ul>
Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal...
2009-10-28T16:43:46 WARNING LinguaPlone The thread number -1337921536 doesn't  have an associated request object. ------ 2...
Logging level <ul><li>Analyzing Zope's event log:
INSTANCE_HOME/etc/zope.conf </li></ul><eventlog> level info <logfile> path $INSTANCE/log/event.log level info  # &quot;CRI...
Logging yourself <ul><li>Logging to event log from product code: </li></ul>>>> import logging >>> logger = logging.getLogg...
System logs $ tail -f /var/log/system.log <ul>Specially if connecting with other applications (mail server, etc) </ul>$ ta...
Instance not responding <ul><li>Make sure that Zope is failing: </li></ul>$ telnet localhost 80  Trying ::1... telnet: con...
Instance not responding $ telnet localhost 80  Trying ::1... telnet: connect to address ::1: Connection refused Trying 127...
Instance not responding <ul><li>Make sure that ZEO is responding: </li></ul>$ telnet localhost 81 Trying ::1... telnet: co...
Instance not responding <ul><li>Start Zope in foreground: </li></ul>$ INSTANCE_HOME/bin/zopectl fg <ul><li>Start Zope in d...
Instance not responding <ul><li>About Zope debug mode: </li><ul><li>Errors in product initialization prevent startup
Elements from skin layers (templates, scripts, etc) can be edited while the server is running </li></ul></ul><ul><li>Start...
recipe = plone.recipe.zope2instance
debug-mode = on </li></ul></ul>
Zope Python console <ul><li>Access database directly: </li></ul>$ INSTANCE_HOME/bin/zopectl debug Starting debugger (the n...
Zope Python console <ul><li>Tab completion: </li></ul>>>> import rlcompleter >>> import readline >>> readline.parse_and_bi...
Zope Python console <ul><li>Synchronization: </li></ul>>>> app._p_jar.sync() <ul><li>Transactions: </li></ul>>>> import tr...
Python debugger <ul><li>Set a breakpoint: </li></ul><ul><li>Post-mortem: </li></ul>try: return self.getField('photo').tag(...
Server IO errors <ul><li>“ No space left on device” </li></ul><ul><ul><li>Check disc space available for database
Check disc space at  /tmp  dir </li></ul><li>Other errors: </li><ul><li>“ No such file or directory”
“ Too many open files”
“ Read-only file system”
... </li></ul></ul>
Debugging security issues <ul><li>Default traceback gives poor information: </li></ul>... Module Products.CMFPlone.browser...
Upcoming SlideShare
Loading in...5
×

Troubleshooting Plone

4,664

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,664
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
47
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Troubleshooting Plone

  1. 1. Troubleshooting Plone Ricardo Alves [email_address] Plone Conference 2009 - Budapest
  2. 2. What can go wrong?
  3. 3. Main Issues <ul><li>Site errors and broken objects
  4. 4. Instance not responding
  5. 5. Server IO errors
  6. 6. Unauthorized / security errors </li></ul>
  7. 7. Site Errors <ul><li>Analyzing the traceback at error_log:
  8. 8. http://mysite/plonesite/error_log/manage_main </li></ul>
  9. 11. Site Errors <ul><li>Analyzing Zope's event log:
  10. 12. INSTANCE_HOME/logs/event.log </li></ul>
  11. 13. Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal Module zope.tales.tales, line 696, in evaluate - URL: file:/Users/rsa/eurotux/udp/iporto/bundle/plone/CMFPlone/skins/plone_content/newsitem_view.pt - Line 41, Column 15 - Expression: <PythonExpr here.tag(scale='mini', css_class='newsImage')> - Names: {'container': <PloneSite at /plone>, 'context': <ATNewsItem at /plone/new-website-soon>, 'default': <object object at 0x395528>, 'here': <ATNewsItem at /plone/new-website-soon>, 'loop': {}, 'nothing': None, 'options': {'args': ()}, 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x6f4c0d0>, 'request': <HTTPRequest, URL=http://localhost:9095/plone/new-website-soon/newsitem_view>, 'root': <Application at >, 'template': <FSPageTemplate at /plone/newsitem_view used for /plone/new-website-soon>, 'traverse_subpath': [], 'user': <PropertiedUser 'admin'>} Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__ - __traceback_info__: here.tag(scale='mini', css_class='newsImage') Module PythonExpr, line 1, in <expression> Module Products.ATContentTypes.content.newsitem, line 130, in tag AttributeError: 'NoneType' object has no attribute 'tag'
  12. 14. 2009-10-28T16:43:46 WARNING LinguaPlone The thread number -1337921536 doesn't have an associated request object. ------ 2009-10-28T16:45:00 INFO SignalHandler Caught signal SIGINT ------ 2009-10-28T16:45:00 INFO Z2 Shutting down ------ 2009-10-28T16:45:21 INFO ZServer HTTP server started at Wed Oct 28 16:45:21 2009 Hostname: 0.0.0.0 Port: 9095 ------ 2009-10-28T16:45:23 INFO Marshall libxml2-python not available. Unable to register libxml2 based marshallers. ------ 2009-10-28T16:45:27 INFO ZEO.ClientStorage (4478) ClientStorage (pid=4478) created RW/normal for storage: '1' ------ 2009-10-28T16:45:27 INFO ZEO.cache created temporary cache file '<fdopen>' ------ 2009-10-28T16:45:27 INFO ZEO.ClientStorage (4478) Testing connection <ManagedClientConnection ('127.0.0.1', 9096)> ------ 2009-10-28T16:45:27 INFO ZEO.zrpc.Connection(C) (127.0.0.1:9096) received handshake 'Z303'
  13. 15. Logging level <ul><li>Analyzing Zope's event log:
  14. 16. INSTANCE_HOME/etc/zope.conf </li></ul><eventlog> level info <logfile> path $INSTANCE/log/event.log level info # &quot;CRITICAL&quot;, 'ERROR&quot;, WARN&quot;, &quot;INFO&quot;, # &quot;DEBUG&quot;, and &quot;ALL&quot; </logfile> </eventlog> <logger access> level WARN <logfile> path $INSTANCE/log/access.log format %(message)s </logfile> </logger>
  15. 17. Logging yourself <ul><li>Logging to event log from product code: </li></ul>>>> import logging >>> logger = logging.getLogger('My package') >>> logger.log(logging.INFO, 'My message') >>> context.plone_log('My message') <ul><li>From skin layers (as Plone): </li></ul>
  16. 18. System logs $ tail -f /var/log/system.log <ul>Specially if connecting with other applications (mail server, etc) </ul>$ tail -f /var/log/messages $ tail -f /var/log/system.log
  17. 19. Instance not responding <ul><li>Make sure that Zope is failing: </li></ul>$ telnet localhost 80 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /plone HTTP/1.1 HTTP/1.1 200 OK Server: Zope/(Zope 2.10.4-final, python 2.4.4, darwin) ZServer/1.1 Plone/3.1.7 Date: Wed, 28 Oct 2009 19:13:49 GMT Content-Length: 20541 Expires: Sat, 1 Jan 2000 00:00:00 GMT Content-Type: text/html;charset=utf-8 Content-Language: en <!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot; http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd &quot;> ...
  18. 20. Instance not responding $ telnet localhost 80 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /plone HTTP/1.1 HTTP/1.1 404 Not Found Server: Zope/(Zope 2.10.4-final, python 2.4.4, darwin) ZServer/1.1 Plone/3.1.7 Date: Wed, 28 Oct 2009 19:16:57 GMT Bobo-Exception-Line: 100 Content-Length: 812 Bobo-Exception-Value: See the server error log for details Content-Type: text/html; charset=iso-8859-15 Bobo-Exception-Type: NotFound Bobo-Exception-File: BaseRequest.py <html> <head><title>Zope</title></head> ...
  19. 21. Instance not responding <ul><li>Make sure that ZEO is responding: </li></ul>$ telnet localhost 81 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Z303
  20. 22. Instance not responding <ul><li>Start Zope in foreground: </li></ul>$ INSTANCE_HOME/bin/zopectl fg <ul><li>Start Zope in debug mode: </li><ul><li>INSTANCE_HOME/etc/zope.conf: </li></ul></ul># Directive: debug-mode ... # # Setting this to 'off' when Zope is in a production environment is # encouraged, as it speeds execution (sometimes dramatically). # # Default: off # # Example: # debug-mode on
  21. 23. Instance not responding <ul><li>About Zope debug mode: </li><ul><li>Errors in product initialization prevent startup
  22. 24. Elements from skin layers (templates, scripts, etc) can be edited while the server is running </li></ul></ul><ul><li>Start Zope in debug mode: </li><ul><li>buildou.cfg </li></ul></ul><ul><ul><li>[instance]
  23. 25. recipe = plone.recipe.zope2instance
  24. 26. debug-mode = on </li></ul></ul>
  25. 27. Zope Python console <ul><li>Access database directly: </li></ul>$ INSTANCE_HOME/bin/zopectl debug Starting debugger (the name &quot;app&quot; is bound to the top-levelZope object) >>> app <Application at > >>> app.plone <PloneSite at /plone> >>> app.plone.portal_catalog(portal_type='News Item') [<Products.ZCatalog.Catalog.mybrains object at 0x669e270>] >>>
  26. 28. Zope Python console <ul><li>Tab completion: </li></ul>>>> import rlcompleter >>> import readline >>> readline.parse_and_bind(&quot;tab: complete&quot;) >>> app.plone.portal_catalog.search<TAB PRESSED> <ul><li>Authentication: </li></ul>>>> from AccessControl.SecurityManagement import newSecurityManager >>> app.acl_users.getUserById('admin').__of__(app.acl_users) >>> newSecurityManager(None, user)
  27. 29. Zope Python console <ul><li>Synchronization: </li></ul>>>> app._p_jar.sync() <ul><li>Transactions: </li></ul>>>> import transaction >>> transaction.commit() # Explicit commit >>> transaction.abort() # Transaction aborted >>> transaction.savepoint() # Savepoint >>> app._p_jar.sync() >>> app._p_jar.sync()
  28. 30. Python debugger <ul><li>Set a breakpoint: </li></ul><ul><li>Post-mortem: </li></ul>try: return self.getField('photo').tag(self, **kwargs) except: import pdb, sys e, m, tb = sys.exc_info() pdb.post_mortem(tb) >>> import pdb; pdb.set_trace() INSTANCE_HOMT/plone/ATContentTypes/content/newsitem.py(133)tag()->None -> import pdb; pdb.set_trace( (Pdb) self <ATNewsItem at /plone/new-website-soon> (Pdb) self.getField('image') <Field image(image:rw)> (Pdb) self.getField('photo') >>> import pdb; pdb.set_trace()
  29. 31. Server IO errors <ul><li>“ No space left on device” </li></ul><ul><ul><li>Check disc space available for database
  30. 32. Check disc space at /tmp dir </li></ul><li>Other errors: </li><ul><li>“ No such file or directory”
  31. 33. “ Too many open files”
  32. 34. “ Read-only file system”
  33. 35. ... </li></ul></ul>
  34. 36. Debugging security issues <ul><li>Default traceback gives poor information: </li></ul>... Module Products.CMFPlone.browser.ploneview, line 111, in _initializeData Module plone.memoize.view, line 55, in memogetter Module plone.app.layout.globals.context, line 123, in object_title Module Products.CMFPlone.utils, line 158, in pretty_title_or_id Module Products.CMFPlone.utils, line 463, in base_hasattr Module Products.CMFPlone.utils, line 474, in safe_hasattr Module Shared.DC.Scripts.Bindings, line 184, in __getattr__ Unauthorized: You are not allowed to access 'Title' in this context
  35. 37. Debugging security issues <ul><li>Enable verbose security </li><ul><li>INSTANCE_HOME/etc/zope.conf:
  36. 38. security-policy-implementation python
  37. 39. verbose-security on
  38. 40. buildout.cfg:
  39. 41. [instance]
  40. 42. recipe = plone.recipe.zope2instance
  41. 43. verbose-security = on </li></ul></ul>
  42. 44. Debugging security issues <ul><li>More informative traceback: </li></ul>Module plone.app.layout.globals.context, line 123, in object_title Module Products.CMFPlone.utils, line 158, in pretty_title_or_id Module Products.CMFPlone.utils, line 463, in base_hasattr Module Products.CMFPlone.utils, line 474, in safe_hasattr Module Shared.DC.Scripts.Bindings, line 184, in __getattr__ Module AccessControl.ImplPython, line 563, in validate Module AccessControl.ImplPython, line 461, in validate Module AccessControl.ImplPython, line 808, in raiseVerbose Unauthorized: Your user account does not have the required permission. Access to 'Title' of (ATNewsItem at /plone/new-website-soon) denied. Your user account, usertest, exists at /plone/acl_users. Access requires one of the following roles: ['Contributor', 'Editor', 'Manager', 'Owner', 'Reader']. Your roles in this context are ['Authenticated', 'Member'].
  43. 45. Debugging security issues <ul><li>Reminder about Zope security: </li><ul><li>Permissions -> Roles
  44. 46. Roles -> Principals
  45. 47. Principals (Groups and Users)
  46. 48. Groups -> Users </li></ul></ul>
  47. 49. Debugging security issues <ul><li>Use the Python console: </li></ul><ul>>>> app.plone.restrictedTraverse(' /path/to/object ') </ul>>>> from AccessControl.SecurityManagement import newSecurityManager >>> app.acl_users.getUserById( USERNAME ).__of__(app.acl_users) >>> newSecurityManager(None, user)
  48. 50. Debugging Tools <ul><li>Gloworm: </li><ul><li>http://plone.org/products/gloworm
  49. 51. Firebug-like inspector
  50. 52. Provides usefull information about viewlets and viewlet managers
  51. 53. Includes viewlet management operations </li></ul></ul>
  52. 55. Debugging Tools <ul><li>ZPTDebugger: </li><ul><li>http://plone.org/products/zptdebugger
  53. 56. Debug Python expressions used in page templates
  54. 57. May record information about all templates called
  55. 58. Profilling information </li></ul></ul>
  56. 60. Debugging Tools <ul><li>Clouseau: </li><ul><li>http://plone.org/products/clouseau
  57. 61. A web based (through-the-Plone) Python console
  58. 62. Useful mainly if you don't have access to the filesystem
  59. 63. Nice auto-complete features </li></ul></ul>
  60. 65. Debugging Tools <ul><li>PDBDebugMode: </li><ul><li>http://plone.org/products/pdbdebugmode
  61. 66. Launches a pdb post-mortem debugger on exceptions
  62. 67. Works only in debug mode
  63. 68. Respects ignored exceptions in error_log </li></ul></ul>
  64. 69. Additional Resources <ul><li>Python Debugger: </li><ul><li>http://plone.org/documentation/how-to/using-pdb
  65. 70. http://docs.python.org/library/pdb.html </li></ul></ul>
  66. 71. Questions? Ricardo Alves [email_address]
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×