Your SlideShare is downloading. ×
0
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Troubleshooting Plone
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Troubleshooting Plone

4,612

Published on

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

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Troubleshooting Plone Ricardo Alves [email_address] Plone Conference 2009 - Budapest
  • 2. What can go wrong?
  • 3. Main Issues <ul><li>Site errors and broken objects
  • 4. Instance not responding
  • 5. Server IO errors
  • 6. Unauthorized / security errors </li></ul>
  • 7. Site Errors <ul><li>Analyzing the traceback at error_log:
  • 8. http://mysite/plonesite/error_log/manage_main </li></ul>
  • 9.  
  • 10.  
  • 11. Site Errors <ul><li>Analyzing Zope's event log:
  • 12. INSTANCE_HOME/logs/event.log </li></ul>
  • 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'
  • 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'
  • 15. Logging level <ul><li>Analyzing Zope's event log:
  • 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>
  • 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>
  • 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
  • 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;> ...
  • 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> ...
  • 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
  • 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
  • 23. Instance not responding <ul><li>About Zope debug mode: </li><ul><li>Errors in product initialization prevent startup
  • 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]
  • 25. recipe = plone.recipe.zope2instance
  • 26. debug-mode = on </li></ul></ul>
  • 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>] >>>
  • 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)
  • 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()
  • 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()
  • 31. Server IO errors <ul><li>“ No space left on device” </li></ul><ul><ul><li>Check disc space available for database
  • 32. Check disc space at /tmp dir </li></ul><li>Other errors: </li><ul><li>“ No such file or directory”
  • 33. “ Too many open files”
  • 34. “ Read-only file system”
  • 35. ... </li></ul></ul>
  • 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
  • 37. Debugging security issues <ul><li>Enable verbose security </li><ul><li>INSTANCE_HOME/etc/zope.conf:
  • 38. security-policy-implementation python
  • 39. verbose-security on
  • 40. buildout.cfg:
  • 41. [instance]
  • 42. recipe = plone.recipe.zope2instance
  • 43. verbose-security = on </li></ul></ul>
  • 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'].
  • 45. Debugging security issues <ul><li>Reminder about Zope security: </li><ul><li>Permissions -> Roles
  • 46. Roles -> Principals
  • 47. Principals (Groups and Users)
  • 48. Groups -> Users </li></ul></ul>
  • 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)
  • 50. Debugging Tools <ul><li>Gloworm: </li><ul><li>http://plone.org/products/gloworm
  • 51. Firebug-like inspector
  • 52. Provides usefull information about viewlets and viewlet managers
  • 53. Includes viewlet management operations </li></ul></ul>
  • 54.  
  • 55. Debugging Tools <ul><li>ZPTDebugger: </li><ul><li>http://plone.org/products/zptdebugger
  • 56. Debug Python expressions used in page templates
  • 57. May record information about all templates called
  • 58. Profilling information </li></ul></ul>
  • 59.  
  • 60. Debugging Tools <ul><li>Clouseau: </li><ul><li>http://plone.org/products/clouseau
  • 61. A web based (through-the-Plone) Python console
  • 62. Useful mainly if you don't have access to the filesystem
  • 63. Nice auto-complete features </li></ul></ul>
  • 64.  
  • 65. Debugging Tools <ul><li>PDBDebugMode: </li><ul><li>http://plone.org/products/pdbdebugmode
  • 66. Launches a pdb post-mortem debugger on exceptions
  • 67. Works only in debug mode
  • 68. Respects ignored exceptions in error_log </li></ul></ul>
  • 69. Additional Resources <ul><li>Python Debugger: </li><ul><li>http://plone.org/documentation/how-to/using-pdb
  • 70. http://docs.python.org/library/pdb.html </li></ul></ul>
  • 71. Questions? Ricardo Alves [email_address]

×