Add filetype to list in FileSystem Directory View.

Recently I have added flv file in product skin directory and register flv extension to MIME type registry but it wasn’t listing in product skin directory in ZMI. I was wondering what I was missing after a bit digging I workaround one patch which need to apply at CMFCore/FSFile.py

Basically file extention need to be register in FSFile type.

FSFile.py

registerFileExtension('doc', FSFile)
registerFileExtension('txt', FSFile)
registerFileExtension('pdf', FSFile)
registerFileExtension('flv', FSFile)
registerFileExtension('swf', FSFile)
registerFileExtension('jar', FSFile)
registerFileExtension('cab', FSFile)
registerFileExtension('ico', FSFile)
registerFileExtension('js', FSFile)
registerFileExtension('css', FSFile)
registerMetaType('File', FSFile)

Installing MySQLdb and ZMySQLDA for Zope in Windows

1. Shutdown Zope if running.

2. Copy the directory and files

Download Module Zope_MySQLConnection

MySQLdb
_mysql.pyd
_mysql.exceptions.pyc
_mysql.exceptions.pyo

to the lib/python/ directory inside your Zope instance.

In a generic default install of Zope the location will be:
C:\Zope\Instance\2.10.4\lib\python\

MySQLdb (MySQL for Python) 1.2.2 allows Python to access MySQL using
the Python DB API 2.0 syntax. This version of MySQLdb uses Python
2.4. (The version of Python installed by the Zope 2.10.4 installer
is 2.4.4.) Older/newer versions of Python (2.3, etc.) will not work
with these files, but a version of MySQLdb which does is available from
the sourceforge link below.

(Source: http://sourceforge.net/projects/mysql-python )

3. Copy the directory ZMySQLDA

to the Products/ directory inside your Zope instance.

In a generic default install of Zope the location will be:
C:\Zope\Instance\2.10.4\Products

This is the database adaptor used inside Zope. (ZMySQLDA 2.0.9b3)

(Source: http://sourceforge.net/projects/mysql-python )


4. Restart Zope.

Upon starting Zope you will see a few depreciation warnings. These
are no cause for alarm, however ZMySQLDA will apparently need to be
updated to work with Zope versions 2.11 and above.

If the database adaptor is installed correctly, the item Z MySQL
Database Connection should be available in the “add” dropdown list
and ZMySQLDA should be listed in the collapsable Products menu
(under Control Panel) in the left frame.

You probably need to have installed MySQL and created at least 1
database to add the connection object. The connection string is

database user password

or if there is no user/password simply

database

Click on the connection object to “browse” the database items or enter
“test” SQL queries. If you can browse the database and successfully
enter SQL instructions, the connection between Zope and MySQL **MAY**
be complete. (See below.)

Send email using python script in Plone

If you dont want to hardcode the Mail Host id into your script and want to be able to send email to someone from within a (Script) Python this script will do it.

try:
    mailhost=getattr(context, context.superValues('Mail Host')[0].id)
except:
    raise AttributeError, "cant find a Mail Host object"

mMsg = 'a testful email message \n that contains a few line breaks. \n ~runyaga'
mTo = 'runyaga@abc.com'
mFrom = 'runyaga@xyz.com'
mSubj = 'mail subject'

mailhost.send(mMsg, mTo, mFrom, mSubj)

Return parent objects of the folder in Zope/Plone Framework

I have spend reasonable time to get parent object for navigation for zope/plone site.I have come up with my script which might be helpful for someone.

root = ('',)
vRoot = context.REQUEST.VirtualRootPhysicalPath
PARENTS = context.REQUEST.PARENTS

PARENTS.reverse()
if vRoot:
    root = vRoot #inside if block
    PARENTS = PARENTS[len(vRoot)-1:] #inside if block

try:
 if PARENTS[-1].meta_type != 'ATFolder':
     return PARENTS[-3]
 else:
     return PARENTS[-2]
except IndexError :
 return PARENTS[0]