Morphex's blogologue (Life, technology, music, politics, business, mental health and more)

This is the blog of Morten W. Petersen, aka. morphex in various places. I blog about my life, and what I find interesting and/or important. This is a personal blog without any editor or a lot of oversight so treat it as such. :)

My email is morphex@gmail.com.

An OGG/Vorbis player, implemented in Javascript.

My Kiva bragging page
My shared (open source) code on GitHub

Morphex's Blogodex

News
Slashdot

Zope hosting by Nidelven IT

Morten Petersen on Linkedin

Morten Petersen on Facebook

Morten Petersen on SoundCloud

Morten Petersen on MixCloud

Blogologue on Twitter



Older entries



Atom - Subscribe - Categories


An updated version of the Issue Dealer, building Zope 2.13.22

It's been a while since I did anything on Zope 2, and these last couple of months some bugs on the weblog publisher on blogologue.com have been bugging me.

So I decided I should get that fixed, and also get the IssueDealer updated to work with the latest stable version of Zope 2.

It has been some days of fixing things back and forth to get things working, but now I have an updated version of the IssueDealer, as well as a procedure for building the latest and greatest Zope 2.

I've been quite out of touch with what has been going on in the Zope, Plone and Python world lately, and it took me quite some effort to get things working, from getting Zope from GitHub, getting the right dependencies in etc. One thing I've noticed is that pypi.python.org is using a common name of www.python.org - which forced me to make a shell script to aid in the process of setting up Zope. This is sloppy at best, as it forces users to skip SSL verification.

But, enough of that, here's the hands on procedure for getting Zope 2 installed on a Debian Linux box. Beforehand, I think it's necessary to install the build-essential package as well as git, in other words:

sudo apt-get install build-essential git

I'm not sure what the procedure is for Fedora/Red Hat, SuSe etc. is but it should be easy enough to figure out.

OK. We'll install Python and Zope in a directory called

/home/morphex/zope_blogologue.com

First thing we do is get Python 2.7.9 installed, which is done with

mkdir zope_blogologue.com
chmod o-rwx zope_blogologue.com # So other users can't read the database etc.
cd zope_blogologue.com
mkdir tmp
cd tmp
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar xfz Python-2.7.9.tgz
cd Python-2.7.9/
./configure --prefix=/home/morphex/zope_blogologue.com
make install
cd /home/morphex/zope_blogologue.com/
git clone https://github.com/zopefoundation/Zope zope
cd zope
git checkout 2.13.22
wget --no-check-certificate https://raw.githubusercontent.com/morphex/IssueDealer/master...
chmod +x bootstrap.sh
./bootstrap.sh ~/zope_blogologue.com/bin/

Now, edit the buildout.cfg file, so that the [zopepy] and [wsgi] sections contains the line

    Products.IssueDealer==0.9.140

like so, maybe using the command "nano buildout.cfg":

[...]
[zopepy]
recipe = zc.recipe.egg
eggs = Zope2
    Products.IssueDealer==0.9.140
interpreter = zopepy
scripts = zopepy
[...]
[wsgi]
recipe = zc.recipe.egg
eggs =
    Zope2
    repoze.who
    repoze.tm2
    repoze.retry
    Paste
    PasteDeploy
    PasteScript  
    Products.IssueDealer==0.9.140

Now, when that's done, we're ready to run buildout. Run the command

./bin/buildout

Now, this script may fail, if there are network issues for example that make downloading of packages break. If that's the case, just re-run the command until it completes with lines something like this:

"""
Generated script '/home/morphex/zope_blogologue.com/zope/bin/runzope'.
Generated script '/home/morphex/zope_blogologue.com/zope/bin/zopectl'.
Generated script '/home/morphex/zope_blogologue.com/zope/bin/zpasswd'.
Generated script '/home/morphex/zope_blogologue.com/zope/bin/addzope2user'.
Generated script '/home/morphex/zope_blogologue.com/zope/bin/mkzopeinstance'.
Generated script '/home/morphex/zope_blogologue.com/zope/bin/paster'.
"""

After a lengthy process with lots of output, we can create the Zope instance, like so:

./bin/mkzopeinstance -d ~/zope_blogologue.com/zope/instance

I'll leave it up to you to choose a username and password.

Now the instance has been setup, and we can run it for the first time. Type in the command

./instance/bin/zopectl fg

And you should see something like this:

/home/morphex/zope_blogologue.com/zope/instance/bin/runzope -X debug-mode=on
2015-02-13 04:31:04 INFO ZServer HTTP server started at Fri Feb 13 04:31:04 2015
        Hostname: 0.0.0.0
        Port: 8080
2015-02-13 04:31:05 INFO Zope Ready to handle requests

Now I login to my server on the URL http://blogologue.com:8080/manage_main - and select "Issue Dealer" from the drop-down list, click on add and give it the ID issues, and the title "My issues". Now that Issue Dealer instance is available on

http://blogologue.com:8080/issues

Voila. If you're setting up a plain Zope 2 or Zope 2 with some product, just remove the Products.IssueDealer parts from the buildout.cfg and it should work.

Hope you found this useful, and comments etc. are much appreciated. My email is morphex AT gmail.

[Permalink] [By morphex] [Zope (Atom feed)] [13 Feb 04:05 Europe/Oslo]

Two quick hits

Recently I ran into a couple of .. issues where customers had either made mistakes or couldn't figure out things.

These were issues that I had run into earlier so being slightly annoyed (itch) I decided it was time to do something about it (scratch).

The first was a customer who managed to run a link-checker on their Plone site, and having the link-checker be logged in, which wrecked havoc as a lot of things in Plone can be done by clicking links. So they had well over a thousand transactions done in the course of 4-5 hours. Restoring from backup would've been simple enough but some important changes had been made prior to this "bot attack" so I didn't see reverting to backup as an option.

This is something that has been a problem earlier as well, so I decided to dig a bit into the undo machinery of Zope to see if it could be fixed. And there, after reading a little bit of code I could see that it would be possible to undo things based on a date. So I wrote up a tool in a couple of hours to test this theory and to my pleasurable surprise it worked.

The product-ified version of this fix can be found here

  http://products.nidelven-it.no/undoer

it should probably be a part of the Zope core distribution (it's an obvious, useful feature) but I'm too lazy to get it submitted. If someone wants to do it, feel free to do so - I'll slip it under the ZPL or something similar.

Another thing that bugged me was a customer that was using up a lot of diskspace (itch) (which we would have to charge for) but they claimed they weren't adding large objects to the database. So, fair enough - this is something I've dealt with before and I got another idea: use the database export feature to get a readout on which objects in the database were using the space (scratch); the result is here:

  http://products.nidelven-it.no/spaceman

a rather cool hack in my opinion, which uses a dummy file to get a count on which objects are taking up space. Turns out something in the customer's system was writing transactions (and often) so a database pack discarding *all* old transactions was all that was needed.

Now, it would be interesting (and fairly easy) to see what's writing all those transactions as well, but that's one for later.

[Permalink] [By morphex] [Zope (Atom feed)] [13 Mar 19:31 Europe/Oslo]