Tareq Alam

i have promises to keep and miles to go before i sleep – Robert Frost

ZopeSkel Archetypes HOWTO September 8, 2009

Filed under: 1 — tareqalam @ 5:38 am
Tags: , , , ,

This is amazing help. To create simple archtype based product in plone follow the steps in this link
http://lionfacelemonface.wordpress.com/tutorials/zopeskel-archetypes-howto/

 

pdflatex running silentmode June 24, 2009

Filed under: 1 — tareqalam @ 10:33 am
Tags: , , , , ,

run this command in terminal to create pdf from the tex file silently

pdflatex -interaction=batchmode texfilename.tex

 

PIL: IOError: encoder jpeg not available June 2, 2009

Filed under: 1 — tareqalam @ 7:07 am
Tags: , , , , ,

I have got this error while doing this
import tempfile
bg_new=Image.new(‘RGB’,(486,236), GREEN)
tmp = tempfile.mktemp(suffix=’.%s’ % ‘jpg’)
bg_new.save(tmp, “JPEG”, quality=95)

I was looking for solution and got this:

in setup.py in Imaging-1.1.6 that is PIL 1.1.6
set this
JPEG_ROOT = “/usr/lib64″, “/usr/include”
then in terminal
python setup.py build –force
this will include libjpeg in PIL. before you may need to install libjpeg in your linux system. I have tried this with python2.4 in ubuntu 8.10
hope this works

 

how to add external method while installing product in plone May 6, 2009

Filed under: 1 — tareqalam @ 11:27 am
Tags: , , , ,

in profiles/default create import_steps.xml

Import easysearch settings

in the product create setuphandlers.py file like this

# created by tareq alam
# tareq.mist@gmail.com
# www.commitmentsoft.com
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_hasattr
from Products.Archetypes.public import listTypes

def importVarious(context):
"""
Final easysearch import steps.
"""

site = context.getSite()
invokeFactory = getToolByName(site, 'invokeFactory')
manage_delObjects = getToolByName(site, 'manage_delObjects')
#getattr = getToolByName(site, 'getattr')

try:
manage_delObjects("reportExternalMethods")
except:
pass
Newfolder = invokeFactory("Folder", id="reportExternalMethods", title="reportExternalMethods",path='/')
Newfolderobj = getattr(site, Newfolder, None)
manage_addProduct = getToolByName(Newfolderobj, 'manage_addProduct')

em = manage_addProduct['ExternalMethod']
manage_addExternalMethod = getToolByName(em, 'manage_addExternalMethod')
manage_addExternalMethod('imageexample', 'imageexample', 'easysearch.imageexample', 'imageexample')
manage_addExternalMethod('createResultPy', 'createResultPy', 'easysearch.createResultPy', 'createResultPy')

#em = context.manage_addProduct['ExternalMethod']

now restart and install product
this will create a folder reportExternalMethods in root .. and also create two external methods in that folder

 

sound prblem fix hp dv 7 laptop in ubuntu April 29, 2009

Filed under: 1 — tareqalam @ 5:32 am
Tags: , , , ,

thanks to this links creator
http://forum.notebookreview.com/showthread.php?t=331172

 

download xml of various settings of plone from zmi April 1, 2009

in zmi of plone click on portal_setup
click on export tab
click on export selected steps button and save in local
done
u can now use these xmls where u need them

 

add contents and publish in plone using python script March 30, 2009

add a external method
in the method’s python file

Newfolder = context.invokeFactory(“Folder”, id=”NEWFOLDERINPLONE”, title=”NEWFOLDERINPLONE”,path=’/’.join(context.getPhysicalPath()))
this will add a new folder in the contexts directory
To publish this folder automatically by code try this magic

Newfolderobj = getattr(context, Newfolder, None)
review_state = Newfolderobj.portal_workflow.getInfoFor(Newfolderobj, ‘review_state’, ”)
if not review_state == ‘published’:
Newfolderobj.portal_workflow.doActionFor(Newfolderobj,”publish”,comment=”publised programmatically”)

it will be published in site on the fly…

to add page template

idict = { ‘id’ : ’step1Page’
, ‘type’: ‘page template’
, ‘body’: page_template_body # variable can be a content of a pt file
, ‘workflow_action’: ‘publish’
, ‘workflow_comment’: ‘This item published programmatically’

}

Newfolderobj.manage_addProduct['PageTemplates'].manage_addPageTemplate(id=idict['id'])
oi = getattr(Newfolderobj,idict['id'])
oi.pt_edit(idict['body'],’text/html’)

this will add a page template in new folder
together


def main(self):

# Example code:

# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
context = self
try:
Newfolder = context.invokeFactory("Folder", id="NewFolderUnusedId", title="NewFolderUnusedId",path='/'.join(context.getPhysicalPath()))
except:
Newfolder = 'NewFolderUnusedId'

Newfolderobj = getattr(context, Newfolder, None)

review_state = Newfolderobj.portal_workflow.getInfoFor(Newfolderobj, 'review_state', '')
if not review_state == 'published':
Newfolderobj.portal_workflow.doActionFor(Newfolderobj,"publish",comment="publised programmatically")
f=open("somefile.pt","r")
page_template_body = f.read()
f.close()
idict = { 'id' : 'step1Page'
, 'type': 'page template'
, 'body': page_template_body
, 'workflow_action': 'publish'
, 'workflow_comment': 'This item published programmatically'

}

Newfolderobj.manage_addProduct['PageTemplates'].manage_addPageTemplate(id=idict['id'])
oi = getattr(Newfolderobj,idict['id'])
oi.pt_edit(idict['body'],'text/html')
return true

 

Add new widget in PloneFormGen March 30, 2009

PloneFormGen is a nice tool to add dynamic forms in plone
There are lot of different form fields in PloneFormGen
but I was in need of a new type of widget in my form
this is how i did that

first to learn how it works..
http://plone.org/products/pfgdatagrid
download this product and install it after installing DataGridWidget and PloneFormGen

now you can add datagrid widget directly in plone form folder

to use a new type of widget as like data grid widget you can do the following steps
1. copy the PFGDataGrid and paste with name as you like for example PFGNoneMultiSelectionWidget
2. inside the folder change in the following files
content
__init__.py will contain import nonemultiselectionff
rename the datagridff.py to nonemultiselectionff.py
in every file in every folder
also in nonemultiselectionff.py you have to define the schema and the function
for this you need to study and this is different for different widgets
you have to define functions so that you can take the widget from the products folder
follow example in datagridfield and in ploneFormGen fields.py for ideas
or call me ;)
change PFGDataGrid to PFGNoneMultiSelectionWidget
and change FormDataGridField to FormNoneMultiSelectionWidget

 

XLS: DATE() function to convert integer to date and get date difference December 11, 2008

Filed under: 1 — tareqalam @ 5:18 pm

Problem: I have two cell with integer value like this in A1: 20080101 and n C1: 20080116. These are dates but in integer field. I need to put the difference of date between C1 and A1 in B1

Solution: click on B1 in the function bar type this:

=(DATE(LEFT(C1,4),MID(C1,5,2),RIGHT(C1,2)) -DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2)))

and press enter.

its solved.

 

Internet explorer loads same image more than once with ajax December 5, 2008

In Internet Explorer  when an html is loaded with image inside if the image is same in all img tag internet explorer loads the image each time it foinds in img tag.. this makes the ajax loading slower. AJAX is used to make a web page faster but IE seems having problem with that.

To solve this i have applied an idea .. searching google i came to know that IE loads single time of same image located in style background of an element. so I made img tag to div with style background property to the src of the image … now if i load 100 of that div via ajax it loads only one time. Thus my web page loads faster in IE.. Thanks to FireFox it behaves nice with this problem.

Hope this helps