Spiga
Showing posts with label Zope. Show all posts
Showing posts with label Zope. Show all posts

Exporting Plone3.0 Memberdata and Passwords

I need to export plone accounts from Inigo Intranet to LDAP. To accomplish that, first I need some way to export the data I need. Plone itself does not have such tool for it (that I know of).

Not so long ago, Kaeru pointed me to a zope script for such purpose, however, the script fails to extract passwords from Plone3.0 mainly due to passwords are now managed by the PluggableAuthService - which made getPassword() to return None and _getPassword() to raise NotImplementedError. I don't know whether somebody forgot to implement those functions into PAS or it was purposely done. Googling lead me to this page in plone.org and from there, to this other script. Again, none of them able to extract the password hashes. I lost hope with google, and to the source I went.

After a whole night digging through the plone source, at last, I managed to found the method to extract the hash. So, heres the External Script which I wrote to extract stuff I want.


# Memberdata export script for Plone 3.0
#
# based on:
# http://transcyberia.info/archives/23-howto-sync-mailman-from-plone.html
# http://www.zopelabs.com/cookbook/1140753093
# http://plone.org/documentation/how-to/export-member-data-to-csv
#
# desc:
# None of the scripts above can extract password hashes on Plone3.0,
# BUT THIS ONE CAN!!!
#
# Execute this as normal External Script, and DON'T make it public accessible
# (unless you don't mind people having your hashes). You have been warned.
# Have fun (^,^)
#


from StringIO import StringIO
import csv
import time

def getMembersCSV(self):

request = self.REQUEST
text = StringIO()
writer = csv.writer(text)

# core properties (username/password)
core_properties = ['member_id','password']

# extra portal_memberdata properties
extra_properties = ['fullname',
'email',
'location',
'home_page',
'description']

properties = core_properties + extra_properties

writer.writerow(properties)

membership=self.portal_membership
passwdlist=self.acl_users.source_users._user_passwords

for memberId in membership.listMemberIds():
row = []
for property in properties:
if property == 'member_id':
row.append(memberId)
elif property == 'password':
row.append(passwdlist[memberId])
else:
member = membership.getMemberById(memberId)
row.append(member.getProperty(property))

writer.writerow(row)


request.RESPONSE.setHeader('Content-Type','application/csv')
request.RESPONSE.setHeader('Content-Length',len(text.getvalue()))
request.RESPONSE.setHeader('Content-Disposition',
'inline;filename=members-%s.csv' %
time.strftime("%Y%m%d-%H%M%S",time.localtime()))

return text.getvalue()


Have fun (^.^)

Qemu slow disk throughput

I am doing some development for a UN community site, using Zope/Plone. I uses Qemu for hosting the guest OS for my development environment.

For 2 days, I keep wondering why Zope/Plone loads damn slow on the qemu machine eventhough I have allocated both cores of the processor, and 512RAM for it. 15 minutes simply to start up is really not desirable. I kept on investigating and guess what:

[root@unapcict ~]# /sbin/hdparm -t /dev/hda

/dev/hda:
Timing buffered disk reads: 18 MB in 3.03 seconds = 5.95 MB/sec


Just for a comparison, the host hdd's speed:

[root@Nobuyuki ~]# /sbin/hdparm -t /dev/sdc

/dev/sdc:
Timing buffered disk reads: 174 MB in 3.01 seconds = 57.71 MB/sec


Darn.. So, thats what the reason. Dear lazywebs, anybody know how to improve the speed??.

Zope/Plone on Fedora

My industrial internship with Inigo Technologies requires me to run a distro which have python2.4. Being someone who prefer to stick on RPMS rather than source-based installation, I ran CentOS on Xen of my home fileserver for Zope/Plone support.

While wasting my time browsing through pirut a few days ago, I noticed compat-python/compat-zope/compat-plone on Livna repository. I know those packages exist by Jonathan Stefan, but didn't know that its on Livna. Anyway, cool, now I can play with zope on my laptop directly :D.

A month with FreeBSD, Zope and Plone

For the past month, I have been working as an intern at Inigo Tech. The company focuses on Zope and Plone deployment and customization and I'm the sysadmin of the company server.

FreeBSD

The company server uses FreeBSD as the OS with several BSD Jails on top of it. BSD Jails is one of the virtualization technology on the OS level. Unlike Xen, Qemu and VirtualBox, Jails is a very lightweight virtualization where the Guest environment does not run any kernel on it. While Xen, Qemu and VirtualBox allows different OSes running as Guest, Jails can only support another BSD installations.

I found that Jails is very useful for those who only needs better process and environment separation and doesn't need another full blown OS features. Interested to know what available on the Linux world for this, I went googling and found the Linux-Vserver Project and the OpenVZ Project. However, the RPM packages provided by both of them (especially the kernel) are quite not in sync with the current Fedora repositories. So, if anybody thinking of trying them out, I would recommend installing on CentOS or a Debian derivative instead as the packages does not being updated as fast as Fedora. Btw, if anybody successfully deployed a OpenVZ guest, can you post me an easy to follow guide??. As I'm quite confused with the OpenVZ documentations (the templates etc).

But so far, I think thats the only thing I liked from the BSD world. Everything else, are kindof PITA and not elegant in my point of view. Perhaps because I have been pampered by RPM way too much. Ports, while have quite a large collection of packages, is not as elegant as RPM or DEB in package management. If only for installation and removal of packages, Ports works quite well, but if I want to do extra stuff to the installed files, everything went messy. Dependency hell, I dont know how many times i've faced that in Ports. Updating and removing packages feels quite scary when it might causes another app, hidden somewhere, to have a library problem. For the filesystem hierarchy and file placements, is another messy thing as trying to separate stuff that maintained by package manager and stuff that are done by local user is not as clear as in RPM distros. But for this, I might be biased as I come from the Red Hat Linux / Fedora Linux origins and still not that experienced in BSD. Perhaps after exploring and learning more about the BSD way of doing stuff, I might change my opinion on this.

Zope and Plone

In Inigo Tech, I was introduced for the first time to Zope and Plone. I have heard about it before, and followed the debate on Fedora mailing list about why Fedora 7 could not support Zope and Plone due to Python2.5, but I had never tried using it firsthand. What I know about during that time Zope was that its something like Tomcat but in Python, with Plone as one of the most popular app running on Zope.

After this whole month of using Zope and Plone, I grown to like it and the ideas it brought together. I have been a fan of proper separation of services and environments since I learned about virtualization. So, I feel Zope is a great platform. A virtual filesystem on an ORDB? Cool!. Full separation of the web environment and the host server? Great!. Using Instances instead of a full copy of files? Yay!. Plugins architechture, of which different instances can have different set of Plugins? Superb!. All in all, I love Zope, except for maybe, the ZMI which looks kind of cluttered, but looks good or not is a matter of who looking at it :).

As for Plone, Inigo sees it as an alternative to Microsoft SharePoint. As I had never tried out SharePoint, I couldn't comment much about their differences/similarities. But one thing I know, Plone offers more features that SharePoint in term of document management and sharing, Plone is easier to use than SharePoint, Plone can work nicely with commodity softwares while SharePoint requires you to upgrade to IE7, Vista, Office 2007 etc, and best of all, Plone is Free! and SharePoint is dictated by Microsoft (>.<) . So, that makes it Plone is better than SharePoint right? So if your company want to buy SharePoint, how about you look at Plone first before deciding ;).

======

All in all, working with Inigo is fun with all these. I'm glad I took Kaeru's offer and not other internship offers with other companies. Plus, I got to telecommute. Saved some hassle of transportation, food, etc :D