Nidelven IT - All about Python, Zope & Plone - and Open Source!

Here you'll find issues related to our services. Mostly about Python, Zope and Plone, as well as hosting-related issues.

"Keeping IT real"






Older entries



Atom - Subscribe - Categories

Object missing or not found [Deleted]

The object pointed to is missing - this issue is used to help with broken pointers

[Permalink] [By morphex] [All (Atom feed)] [Comments] [07 Sep 21:09 GMT+2]

Update on decommissioning old mail server

If you've gotten another deadline for downloading mail by those who manage the mailserver, or another message from them, then you could forward that message to Nidelven IT LTD, to morten@nidelven-it.no. It is another company that operates the server, and it is not under Nidelven IT's direct control.

So whatever they decide will probably be how it ends up being.

If something is urgent or you suspect your mail is not getting through to Nidelven IT LTD, it is possible to send an SMS to +47 415 14 316 for the next few weeks regarding this. But please keep the SMS short, and put what's important in an email.

[Permalink] [By morphex] [Manager (Atom feed)] [Comments] [20 Jan 15:57 GMT+2]

Decommissioning old mail server

Hi.

This is the manager and owner of Nidelven IT LTD writing to you. The mail server mailgateway.no will be taken down in not too long.

There could be old emails there, so if you have in the past had a mail service associated with us, either through Aktivnett (WOW Webdesign), WOW Medialab, others or directly with us, you should take copies of your emails on that server as soon as possible, preferably within a couple of weeks, the deadline is 4 weeks from now, on the 17th of February 2021.

If you want us to download a copy of your emails and send it to you, it is 200 kroner per email account, 50 for each DVD it will take, or 200 for each 16 GB USD drive. That is in Norwegian kroner, NOK.

Nidelven IT LTD makes no guarantees that it will be able to provide this service, but if you don't get what's reasonable to expect, the price for the download and sending email service could be reduced, or refunded in full, and that's it.

I recommend you think carefully about this, as emails could be relevant legal documents, evidence etc. that you might not know you need at this point in time.

Regards,

Morten

[Edit: Added a few hours after posting] If you've gotten another deadline by those who manage the mailserver, or another message from them, then you could forward that message to us, to morten@nidelven-it.no. It is another company that operates the server, and it is not under our direct control. So whatever they decide will probably be how it ends up being.

[Permalink] [By morphex] [Manager (Atom feed)] [Comments] [20 Jan 12:43 GMT+2]

New website launched for customer Elprosjekt Trøndelag

A little while ago we launched a new website, for Elprosjekt Trøndelag.

It's a unique design, and a nice result for a company that works with electrical installations on larger building projects:

http://www.elprosjekt-trondelag.no/

[Permalink] [By morphex] [Websites (Atom feed)] [Comments] [15 Feb 10:29 GMT+2]

An updated version of the Issue Dealer, building Zope 2.13.22

Morten has been blogging again over at http://blogologue.com/blog_entry?id=1423796724X07 about building the latest and greatest Zope + a self-built product.

[Permalink] [By morphex] [Python-only or Python related (Atom feed)] [Comments] [13 Feb 04:41 GMT+2]

A SoundCloud(R) export tool in Python

Morten has been fiddling with Python again, new blog post here: http://blogologue.com/blog_entry?id=1420246529X05

[Permalink] [By morphex] [Python-only or Python related (Atom feed)] [Comments] [03 Jan 02:19 GMT+2]

SASS, Compass & Zen Grid and a maybe new Python Framework?

Morten has been testing out some new technologies, check out his blog post:

http://blogologue.com/blog_entry?id=1417710581X85

[Permalink] [By morphex] [Python-only or Python related (Atom feed)] [Comments] [05 Dec 09:46 GMT+2]

New webshop available / ny nettbutikk tilgjengelig

So, in English first, then in Norwegian. På engelsk først, så på norsk.

OK, so over the course of some years we've been developing a webshop solution for different customer needs, and for well over a year now we've dedicated one developer to further developing the webshop.

There are various options for a new webshop, anything from an out-of-the-box simple webshop setup without much customization, to the most heavily customized webshop imaginable. So there is a wide range of ways the webshop could be setup, from cheap and standard to good-looking and expensive. What kind of setup you want for your organization depends on budget, and how much money you want to put into having an online presence, an online sales channel.

Please do get in touch if this is interesting, info@nidelven-it.no is where we can be reached for questions and comments.

A very old, but working webshop can be seen at http://www.nidelven-it.no/webshop

--

OK, så over noen år nå har vi utviklet en nettbutikk-løsning for forskjellige kundebehov, og i godt over et år nå har vi dedikert en utvikler for å videreutvikle nettbutikken.

Det er forskjellige valg for den nye nettbutikken, alt fra en hyllevare nettbutikk uten mye skreddersøm, til den mest tilpassede nettbutikken som er tenkelig. Det er et vidt spenn med måter nettbutikken kan bli satt opp på, fra billig og standard (funksjonalitet og utseende), til veldig pent og dyrt. Det oppsettet du ønsker for din organisasjon avhenger av budsjett, og hvor mye penger du ønsker å legge i å være på nett, ha en salgskanal på internett.

Vennligst ta kontakt hvis dette er interessant, info@nidelven-it.no er hvor vi kan nås for spørsmål og kommentarer.

En veldig gammel men fungerende nettbutikk kan ses på http://www.nidelven-it.no/webshop


[Permalink] [By morphex] [Webshop (Atom feed)] [Comments] [26 Feb 12:12 GMT+2]

Merry Christmas, and a happy new year!

Thank you for your business this year, we think 2014 will be an interesting and productive year, we have a webshop that has been developed for over a year now that we want to sell some of, and some other things to do.

If there's anything, please mail us at info@nidelven-it.no

[Permalink] [By morphex] [Manager (Atom feed)] [Comments] [23 Dec 18:36 GMT+2]

Quiet and active period

OK, so it's been quiet here for a while. :)

A lot of time has been spent on developing a new webshop concept, my personal focus has been on learning more about sales, and some marketing as well.

The plan now is to do a lot more sales via another company, so if you as a customer have some SaaS solutions, or even other IT-related products we could be interested in hearing from you.

Sites keep running after hosting was sold to another company, so even though we're pretty much out of that business, our customers were and are well taken care of.

Do come in touch if you need some help around anything web-related, we have a lot of experience after all these years and could help you avoid wasting time and money. And even make more money! :)

[Permalink] [By morphex] [Manager (Atom feed)] [Comments] [20 Nov 17:09 GMT+2]

Some security patching to come

There is a security patch coming up for Zope/Plone tomorrow.

We would recommend to all customers that have a Zope/Plone instance to upgrade/migrate to one of the server packages instead, to avoid the risk of server-wide exploits. Get in touch if you want to improve the security of your site(s), for a relatively small cost.

More information will come later today.

[Later..]  There will be downtime related to this fix, so if your site is not responding, don't panic, it should become available as soon as the necessary work has been done to secure the services.

[Permalink] [By morphex] [Hosting (Atom feed)] [Comments] [17 Jun 11:58 GMT+2]

Shutdown of services not paid for

Customers that it hasn't been possible to get in touch with, and that have not paid for their services, will have their services shut down in the time to come.

If your service has been shut down and you want it up and running again, please contact sysadmin@nidelven-it.no

Thank you.

[Permalink] [By morphex] [Hosting (Atom feed)] [Comments] [11 Jun 12:51 GMT+2]

Jep, Jython and CPython compared, all in a nice little script

So, in relation to the work with Jep ( http://www.nidelven-it.no/weblogs/hosting/blog_entry?id=1368... ) - I've been building a script that can build and setup Jep, Jython and CPython in a directory, and then have a compare.sh script that runs the same code on the 3 different systems.

The installation script is here:

https://raw.github.com/morphex/PythonCompare/master/install....

Here's the output from the generated compare.sh file:

morphex@copyleft-laptop:~/projects/self/jython_jepp_installer6$ ./compare.sh
Starting comparison of Jython, Jepp and CPython..
Starting with Jep..
0.39471411705
0.341079950333
0.333596944809
0.34021282196
0.322955131531
0.322613954544
0.322247982025
0.323844909668
0.319895029068
0.324920892715
Ran in milliseconds: 3878.0
Now Jython..
1.25800013542
0.579999923706
0.436999797821
0.361000061035
0.43799996376
0.287999868393
0.289000034332
0.910000085831
0.289000034332
0.290999889374
Ran in milliseconds: 7576
Now CPython..
0.321110010147
0.312225103378
0.312016010284
0.309517145157
0.30745100975
0.313014984131
0.312664985657
0.312491893768
0.311804056168
0.312137126923
Ran in milliseconds: 3165

As you can see, the Jep and CPython scripts are fairly stable in terms of execution speed while Jython varies a bit but gets faster (probably due to the HotSpot technology). If you want to change the test to something else, you can try "./jdk1.7.0_21/bin/java -jar usr/lib/jython-standalone-2.5.3.jar -m compileall -l ." and mytest.py will be recompiled, along with the other .py files.

Now, feel free to use the install.py script as you like, I think it's a good example of how to setup the whole thing in a specific directory.. there was some hair-pulling to get the entire build process setup so that linking and dependencies were setup the right way.

Fun to work with a mix if Python, Java and Bash scripting for a change. I think being able to use Python to script for example prototypes or even production code is a big win in terms of productivity.. weak typing has its place in rapid application development. :)

[Permalink] [By morphex] [Python-only or > 0.5 Python related (Atom feed)] [Comments] [20 May 13:59 GMT+2]

Python in Java

So, these last couple of days I've been playing around with Jep ( http://jepp.sourceforge.net ), the project that embeds Python and makes it available in Java.. it's been a while since I've worked with Java, dependencies and so on, so been pulling hair a bit to get things working.

But, got it working, and one things I've become more aware of lately is how things run, in terms of speed. So I decided to compare Jep, Jython ( http://www.jython.org ) and (C)Python ( http://www.python.org ).

Here's Jep:

>>> from test import pystone
>>> for x in range(10):
... pystone.main()
...
Pystone(1.1) time for 50000 passes = 1
This machine benchmarks at 50000 pystones/second
Pystone(1.1) time for 50000 passes = 1.01
This machine benchmarks at 49505 pystones/second
Pystone(1.1) time for 50000 passes = 1.01
This machine benchmarks at 49505 pystones/second
Pystone(1.1) time for 50000 passes = 1.01
This machine benchmarks at 49505 pystones/second
Pystone(1.1) time for 50000 passes = 1
This machine benchmarks at 50000 pystones/second
Pystone(1.1) time for 50000 passes = 0.99
This machine benchmarks at 50505.1 pystones/second
Pystone(1.1) time for 50000 passes = 1.01
This machine benchmarks at 49505 pystones/second
Pystone(1.1) time for 50000 passes = 1
This machine benchmarks at 50000 pystones/second
Pystone(1.1) time for 50000 passes = 0.99
This machine benchmarks at 50505.1 pystones/second
Pystone(1.1) time for 50000 passes = 1.01
This machine benchmarks at 49505 pystones/second
>>>

It is fairly consistent when it comes to the number of pystones.

Then trying Jython:

>>> for x in range(10):
... pystone.main()
...
Pystone(1.1) time for 50000 passes = 1.816
This machine benchmarks at 27533 pystones/second
Pystone(1.1) time for 50000 passes = 1.128
This machine benchmarks at 44326.2 pystones/second
Pystone(1.1) time for 50000 passes = 0.569
This machine benchmarks at 87873.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.495
This machine benchmarks at 101010 pystones/second
Pystone(1.1) time for 50000 passes = 0.574
This machine benchmarks at 87108 pystones/second
Pystone(1.1) time for 50000 passes = 0.519
This machine benchmarks at 96339.1 pystones/second
Pystone(1.1) time for 50000 passes = 0.497
This machine benchmarks at 100604 pystones/second
Pystone(1.1) time for 50000 passes = 0.501
This machine benchmarks at 99800.4 pystones/second
Pystone(1.1) time for 50000 passes = 0.575
This machine benchmarks at 86956.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.515
This machine benchmarks at 97087.3 pystones/second
>>>

Which shows a great variation, but improvement, in how many pystones can be calculated per second. I assume this is due to the Java HotSpot technology. How well the HotSpot system works with real-life code and data is a different matter.

Finally, we have (C)Python:

>>> for x in range(10):
... pystone.main()
...
Pystone(1.1) time for 50000 passes = 0.86
This machine benchmarks at 58139.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.86
This machine benchmarks at 58139.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.86
This machine benchmarks at 58139.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.85
This machine benchmarks at 58823.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.86
This machine benchmarks at 58139.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.87
This machine benchmarks at 57471.3 pystones/second
Pystone(1.1) time for 50000 passes = 0.87
This machine benchmarks at 57471.3 pystones/second
Pystone(1.1) time for 50000 passes = 0.85
This machine benchmarks at 58823.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.86
This machine benchmarks at 58139.5 pystones/second
Pystone(1.1) time for 50000 passes = 0.86
This machine benchmarks at 58139.5 pystones/second
>>>

Which shows a fairly consistent number of pystones, around 58000 per second.

Now, the reason I started looking at Jython and then Jep, is that I'm looking at some Java-based content and development frameworks. I'm not sure if there is a big difference in how you can use Jep and Jython, but these are alternatives that can be used when developing in Java systems. In most cases data needs to be sent back to the Java-based application.

Being able to script things fast in Python is a benefit in some situations for rapid prototyping and so on. As is my experience with Python, the speed in Python can be good enough with the right programming techniques and systems. If the applications run too slowly, then switching between Jep and Jython can be a good idea to see which one actually runs the fastest.

[Permalink] [By morphex] [Python-only or > 0.5 Python related (Atom feed)] [Comments] [15 May 18:07 GMT+2]

100000 downloads, a significant contribution to the Python community

So, yesterday the counter for downloaded PyPi packages created by me tipped 100000 downloads, which was cool. It has been going steadily for days and months now, and it was nice to see that that magic number was surpassed.

You can see the packages here:

http://blogologue.com/morten%20w.%20petersen%20-%20pypi%20pa...

Most of those packages are tied to the Zope and Plone systems, but at least one package is Python-only, the email_backport package:

"The email_backport package is a wrap-up of the email > 4.x module
found in Python 2.5 and above."

I created that to be able to use mailing features across a large range of Plone versions, and it has worked fairly well.

The more I work with coding and programming, the lazier I get, should really get better at looking for right places to put code in other Python projects or as separate Python software packages, but the most important and pressing thing is to get something working and working well with the code it is supposed to run in and on..

With that thought, it would be nice if we in the Python community get some documentation and training on how to split things into packages, and maybe have some coordinators that can point people in the right direction based on the requirements that have to be fulfilled. There is a lot of redundant code and having quality over quantity is probably better in terms of quality of the code and that focus is on a smaller codebase, which would result in less bugs and maybe more documentation and so on for the projects as well.

[Permalink] [By morphex] [Python-only or > 0.5 Python related (Atom feed)] [Comments] [19 Apr 14:21 GMT+2]

Over 100000 downloads of my Python packages, Archetypes and the future

So, yesterday was a good day for me, programming-wise. The various PyPi packages I've created by myself have been downloaded over 100000 times.

I'm not sure exactly what to make of those statistics, but I think it's safe to guess that at least thousands of somewhat technical users have been using software I've developed lately.

You can see the statistics here:

http://blogologue.com/morten%20w.%20petersen%20-%20pypi%20pa...

Is this something to beat my chest about? Yes, I think so. Open Source projects rely on contributions from the community to thrive (most of the time anyway), and it is nice to be able to give something back and ensure the future of the project for the sake of jobs and users.

The most popular package is MegamanicEdit, a set of code and templates that enables creation of content type in an easier and more refactored way. Dexterity is the new thing in Plone and there's a lot of push to get it adopted, but I think there are also a lot of users of Plone out there that have invested in Archetypes-based solutions.. because of that I'm contemplating forking Archetypes or getting some sort of collaboration in the community to make sure that Archetypes-based code can still be used for a time to come, to basically say that we take care of users of Plone and think about compatability even for older software.

Another think is the license for Plone and its packages, but that discussion has been covered a bit on the mailing lists already, the question is how much work is required to make for example Archetypes more BSD-like so that one can sell off-the-shelf software for Plone as well.

[Permalink] [By morphex] [Python, Zope, Plone - and anything loosely related to that (Atom feed)] [Comments] [19 Apr 14:12 GMT+2]

For the next ones, TinyMCE issues after installing another product

So, I've training a new guy to create new products from scratch, and in that process we encountered an issue with TinyMCE not working after Products.MenuNavigation 1.0a2 was installed.

The product was using the Extensions/Install.py approach on a recent version of Plone 4. Things looked OK, but I could see the TinyMCE editor didn't display as it should. It rendered the textarea in HTML as it should with all the buttons and so on, but only a simple text area was displayed. To make things more interesting, using kupu instead as an editor fixed all problems.

After some debugging and cleaning up of unecessary code, I added profiles/default/metadata.xml, types.xml, types directory with MenuPage.xml and skins.xml. That worked.

So if you encounter something strange with TinyMCE after installing other products, check to see if the new product is using a proper GenericSetup approach, I guess this is the way forward anyway, unless you have a product that is spanning a wide number of Plone versions.

And roll back the transactions from the install new product point, I don't think reinstalling a product with a GS setup profile will fix TinyMCE once it has been broken.

[Permalink] [By morphex] [Python, Zope, Plone - and anything loosely related to that (Atom feed)] [Comments] [21 Mar 14:24 GMT+2]

Getting up to speed with Active Directory, LDAP and Plone

So, we're going after a project that involves a lot of user management, and in that, Windows Active Directory and LDAP to authenticate against and update, so that when someone updates their info in Plone, the AD is also updated.

I haven't worked with a lot of Windows technology on the server side, it has almost always been Linux and other *nix variants.

So, to show that we are able to get things going with Active Directory, LDAP and Plone I figured I could setup VirtualBox on my Linux laptop, and install a trial version of Windows Server.

I downloaded Windows Server 2012, setup VirtualBox, booted from the ISO but the process stopped because the CPU I'm using is 32 (48) bit, and Windows Server 2012 requires 64 bit.

So OK, I googled again after Windows Server 32 bit and found the Windows Server 2008 trial ISO and downloaded that.

OK, so booting up the VirtualBox system with the ISO, getting to the install screen.. Windows asks for a product key but that shouldn't be necessary because I'm doing a trial..

To speed up the installation process I'm choosing the standard core server install.. which wasn't that smart, as the regular start menu and such were not available, just got a command prompt.. so back to the installer, install full standard version and we're up and running. :)

After some trying and failing I found that I could add all the necessary Active Directory bits through Administration tools -> Server Manager. OK, so got those installed, and setup a local DNS server.

Also installed Plone via the Enfold windows installer, as well as the Java JRE, so I could install Apache Directory Studio (which I opted to install after reading some nice things about it on the net).

OK, so after taking a break from this setup process I fired up VirtualBox again and couldn't get the network going. So, back to the Windows Server installation process, install Java, Plone, Active Directory again. This time, Active Directory was only setup with the LDAP module, so I worked with the simplest setup possible.

I tried some different configurations in buildout.cfg to get the plone.app.ldap package going, first issue was that python-ldap couldn't install properly so after some fiddling around I used the msi installer from PyPi and got python-ldap installed on \plone42\python.

OK, so far so good. But buildout still tried pulling and installing python-ldap.. after googling I found that the python-ldap's python egg.info directory moved to the buildout eggs folder fooled buildout to not download python-ldap. And after running buildout, I removed that folder so that there couldn't be any conflicts between the two info folders.

OK, so far so good.. tried firing up the instance and got the following error message:

ImportError: DLL load failed: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail.

Googling I found that it was missing Visual C++ runtime libraries that were missing.. installing runtime libraries for 2005, 2008, 2010 and 2012 (2008 was the right one) that ImportError message disappeared.

So that went fairly well, but starting up with the instance.exe program again raised an ImportError, on win32file. So OK, I looked around and found pywin32 which should contain that module. Downloaded the installer, but didn't get far in the installation process as the Python that comes with the Plone installer doesn't register itself in the windows registry, and it isn't possible to set an installation path manually. So, OK, was about to copy over win32 modules from the new Python 2.6 installation but saw that win32 etc. were already in the site-packages of the Plone installation..

The plot thickens, and again after some Googling it seemed clear that the issue was starting the Plone instance with 'instance.exe fg' didn't work, while starting Plone through the services control panel would.

Well, well. I googled a bit about Enfold plone and finally figured out that there is some LDAP functionality included in the Enfold Plone Server Windows Installer, so I'm going to go for that. Going for server version 4.5 as it looks like the simplest thing to get installed and test how LDAP works with it.

OK, so I tried a bit of this and that, the point of this exercise was to test that it is possible to connect Plone to Active Directory, for retrieval and updating of data..

So, since I'm on a deadline, I decided to go for a simple, verifiable approach to managing AD content. Found pyad, installed Python 2.7, installed pywin32 using the installer, installed easy_install, used easy_install to install pyad. Also setup AD to run Domain Services.

Created the following script:

START

from pyad import pyad
import time

user=pyad.from_cn('Administrator')

for attribute in user.get_allowed_attributes():
    if 'pass' in attribute.lower(): print attribute

print 'old password', user.get_attribute('userPassword')[0][:]
user.update_attribute('userPassword', 'newPassword-' + str(time.time()))

user=pyad.from_cn('Administrator')
print 'new password', user.get_attribute('userPassword')[0][:]

END

And that worked well. It is nice to know that there is a rather uncomplicated way to get access to AD, using Python.

I see that what was Enfold Server will be Open Source, and the plan is to get a proper Plone system integrated with Active Directory in the way most people do, but a simple fallback as described above is nice to have. It would be nice if someone wrote a thorough tutorial or manual on how to integrate Plone with AD, as AD seems to be the choice a lot of organizations use to manage users, access, software licenses and other information.

[Permalink] [By morphex] [Python, Zope, Plone - and anything loosely related to that (Atom feed)] [1 comments] [06 Mar 16:02 GMT+2]

Something that slowed me down a bit today - TinyMCE + old skin

So I got an email from a customer today, having problems with editing news articles and other HTML-content on their site. HTML content was only displayed in a text area, even though the personal settings and plone site were setup to use TinyMCE.

They were upgraded from a prior version that wasn't using TinyMCE as the default editor, so I thought something might be wrong there..

After some work, testing and so on, I finally figured out that the issue was the skin settings in portal_skins - the tinymce folder was listed way below the plone_wysiwyg folder, and then the HTML-code for the editor in the text area was fetched from Plone default, and not TinyMCE.

Pressing customize on the tinymce/wysiwyg_editor template (or something similar) and putting it in the active theme custom folder did the trick, from then on TinyMCE worked well.

Just a tip for the weekend, have a good one. :)

[Permalink] [By morphex] [Python, Zope, Plone - and anything loosely related to that (Atom feed)] [Comments] [01 Mar 17:34 GMT+2]

A walk up the pyramid

So, this Sunday I decided I could play a little around with new technology that I haven't tried much. I've worked with Zope and Plone for years, and it is important stay somewhat in touch with other Python web frameworks - to seize opportunities there as well.

I've seen some buzz about the Pyramid project and especially that it is very promising technically, and lightweight (when something says light-weight in software I think OK, somebody knows what they want and are doing).

So, first thing was to install a fresh Python, as the standard Python setup didn't include easy_install. Installed Python, installed ez_setup.py and then did a 'easy_install -u pyramid'. So far so good. :)

OK, so onto testing this thing out, I followed the first example in this page:

http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch...

and modified it so that the server was running on port 1234, because other ports were taken.

Accessing

http://blogologue.com:1234/hello/man

Gave the result

Hello man!

and yes, that's how easy it was to get up and running. :)

For a while now I've been contemplating building a simple URL shortening service (yes late to the party I know), so I decided I could try to create such a service using Pyramid.

I ended up with this code:

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid import httpexceptions

global urls
urls = []

def redirect(request):
    raise httpexceptions.HTTPFound(urls[int(request.matchdict['index'])])

def index(request):
    try:
        add_url = request.params['b']
        referer = request.referer
        global urls
        urls.append(referer)
        return Response("""Shortened URL: http://blogologue.com:1234/r%s""" %\
                        (len(urls)-1))
    except KeyError:
        return Response("""<html><head><title>Redirect service</title></head>   
    <body><h1>Redirect services</h1>                                            
    <p>Hello there, welcome :)</p>                                              
                                                                                
    <p>To get started using this URL shorting service,                          
    please drag the following link to your bookmark                             
    bar, and click on the link on whatever page you'd                           
    like bookmarked and accessible via this URL shortening                      
    service.</p>                                                                
                                                                                
    <p><a href="javascript:document.location='http://blogologue.com:1234/?b'"   
         >Shorten URL</a></p>                                                   
    </body>                                                                     
    </html>""")

if __name__ == '__main__':
    config = Configurator()
    config.add_route('index', '/')
    config.add_view(index, route_name='index')
    config.add_route('redirect', '/r{index}')
    config.add_view(redirect, route_name='redirect')
    app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 1234, app)
    server.serve_forever()

Which is running on http://blogologue.com:1234 now. Give it a try, in total I think I spent 1 hour setting up Pyramid and getting this URL shortening service running. That is very interesting and promising, think I'll have to find some project to get more familiar with Pyramid.

[Update..] See in the comments section for an updated code example that works harder to get an actual URL.

[Permalink] [By morphex] [Python-only or > 0.5 Python related (Atom feed)] [1 comments] [20 Jan 10:15 GMT+2]