LRU cache invalidation in python

I am getting sucked during writing one of unit test, because one specific function doesn’t works. After huge time spending, it is revealed that I used lru_cache that’s why it just execute one time (could be by another TestCase).

But in the test environment I need fresh result instead of serving from cache for various reasons.

After googling finally I found out real application of cache invalidation. Bellows are example

from functools import lru_cache
def my_function(arg1, arg2)
   return arg1 + arg2
# Clear Cache before calling
my_function(2, 2)


Create custom permission in Plone

How To Make Custom Permission [Addons Development]

As a Plone developer we have to deal with several types of permission, for example  `zope2.View`, `cmf.ModifyPortalContent`.  You can also make your own addons specific; you can do it easily from ZMI but I am going show the persistence way  (via zcml)

For example our zcml file name `permissions.zcml`

<configure xmlns="">

  <permission id="Your Permission Name as Unique ID"
              title="Your Permission Title ">
    <role name="Role Name"/>
    <role name="Role Name"/>
  <permission id="myproduct.addProduct"
              title="My Product Add ">
    <role name="Manager"/>
    <role name="Site Administrator"/>


Now add this file in your addon’s configure.zcml

Example:  <include file=”permissions.zcml” />

Plone Tool sets mapping

Plone Built-in Toolsets

Usually I had been using various tools like `portal_catalog`, `portal_setup` provided by CMFPlone. But all time I was curious, where those tools come from, i mean source so that i can inspect their methods, arguments, parameters etc.

  1. “MailHost”: “Products.MailHost.MailHost.MailHost”
  2. “caching_policy_manager”: “Products.CMFCore.CachingPolicyManager.CachingPolicyManager”
  3. “content_type_registry”: “Products.CMFCore.ContentTypeRegistry.ContentTypeRegistry”
  4. “error_log”: “Products.SiteErrorLog.SiteErrorLog.SiteErrorLog”
  5. “plone_utils”: “Products.CMFPlone.PloneTool.PloneTool”
  6. “portal_actions”:  “Products.CMFPlone.ActionsTool.ActionsTool”
  7. “portal_catalog”: “Products.CMFPlone.CatalogTool.CatalogTool”
  8. “portal_controlpanel”: “Products.CMFPlone.PloneControlPanel.PloneControlPanel”
  9. “portal_css”: “” [Not used in Plone 5.x any more]
  10. “portal_groupdata”: “”
  11. “portal_groups”: “”
  12. “portal_javascripts” : “” [Not used in Plone 5.x any more]
  13. “portal_memberdata”: “”
  14. “portal_membership”: “”
  15. “portal_migration”: “Products.CMFPlone.MigrationTool.MigrationTool”
  16. “portal_password_reset”: “Products.PasswordResetTool.PasswordResetTool.PasswordResetTool”
  17. “portal_properties”:  “Products.CMFPlone.PropertiesTool.PropertiesTool”
  18. “portal_quickinstaller”: “Products.CMFPlone.QuickInstallerTool.QuickInstallerTool”
  19. “portal_registration”: “Products.CMFPlone.RegistrationTool.RegistrationTool”
  20. “portal_skins”: “Products.CMFPlone.SkinsTool.SkinsTool”
  21. “portal_types”: “Products.CMFPlone.TypesTool.TypesTool”
  22. “portal_uidannotation”: “Products.CMFUid.UniqueIdAnnotationTool.UniqueIdAnnotationTool”
  23. “portal_uidgenerator”: “Products.CMFUid.UniqueIdGeneratorTool.UniqueIdGeneratorTool”
  24. “portal_uidhandler”: “Products.CMFUid.UniqueIdHandlerTool.UniqueIdHandlerTool”
  25. “portal_diff”: “Products.CMFDiffTool.CMFDiffTool.CMFDiffTool”
  26. “portal_url”: “Products.CMFPlone.URLTool.URLTool”
  27. “portal_view_customizations”: “”
  28. “portal_workflow”: “Products.CMFPlone.WorkflowTool.WorkflowTool”
  29. “translation_service”: “Products.CMFPlone.TranslationServiceTool.TranslationServiceTool”
  30. “portal_types”: “Products.CMFCore.TypesTool” + “Products.CMFPlone.TypesTool”

How Can I use those Tools
from Products.CMFCore.utils import getToolByName
from plone.api.portal import get as getPortal
from Acquisition import aq_inner

context = aq_inner(context) or portal or getPortal()
portal_catalog = getToolByName(context, 'portal_catalog')

Toolset Source: {eggs}/Products/CMFPlone/profiles/default/toolset.xml

PosgreSQL `hstore` problem in django django.db.utils.ProgrammingError: type “hstore” does not exist

Migration problem while using Django‘s models Hstore fileld (posgres specific)

Django version: 1.8.3

Exception: django.db.utils.ProgrammingError: type "hstore" does not exist


  1. Create a empty migration
    1. ./ makemigrations –name <migration name> <app_label> –empty
    2. example migration file.
    3. Run ./ migrate
    4. No create real migration

assign local role in plone through zmi

Assign local role in plone through zmi

While developing application, some times situation may come to need resource specific permission/authorization. For example, you are member of a development team, so you have a office room with 5 desks for you and your colleague, all of you have equal access to enter into the room but in case of your own desk you are the owner! and you have not same permission for other desks to do anything.

For this situation plone provides very easy solution, you can assign local role for each Archetypes content.  So let’s start your application

  1. Go http://{your portal url}/@@usergroup-userprefs and add new user normally. Oh! please remember the usename.
  2. Go http://{your portal url}/{content url}/manage_listLocalRoles . i.e http://localhost:8080/room/mydesk/manage_listLocalRoles
    1. From left `User` type that username and from right `Role` select your desired role. Don’t worry! you can assign any role even owner, manager; it is local role and will only impact on this content.
    2. North Line Hospital
  3. Go http://{your portal url}/portal_workflow/manage_selectWorkflows
    1. Click `update security settings` button bellow.

Now enjoy the benefits!

Skype problem in Ubuntu

I have faced problems several time while trying start Skype. It doesn’t open, even trying from  terminal! instead of printing this errors
skype: symbol lookup error: /usr/lib/i386-linux-gnu/ undefined symbol: _ZNK14QWidgetPrivate17hasHeightForWidthEv


  1. Open terminal type ~$ sudo nano /etc/
  2. Add this line ` /usr/lib/i386-linux-gnu/mesa/` and press Ctl+X
  3. Finally ~$ sudo ldconfig -v

* My Ubuntu version 14.04 LTS, it should work since 12.04 LTS

** Common FAQ

  • Question: I have already done above & working perfectly but when applying new updates; same problem happen.
  • Answer: Don’t panic please just follow 3 no step. ~$ sudo ldconfig -v

Credit AskUbuntu


Another problem may facing Ubuntu user for Skype, that is Skype open just for a while and stop or could be continuous restarting. [Recently 20th Dec, 2015 I faced this problem, although my OS version is Ubuntu Server 14.04 LTS ]


  • Make sure you have sqlite3 installed in your PC. Other than you can install it easily by following this instruction
  • Go to your terminal (CTRL + ATL +  T)
  • Precaution: The following attempts will remove all of your previous files transfer history
  • $ sqlite3 ~/.Skype/[YOURUSER}/main.db
  • > sqlite> DELETE FROM Messages WHERE type=68;
  • > .quit
  • Congratulation you are done! Try to start skype.