Script Error

Could someone please help me find out what is wrong with this script and if possible how to fix it, I have no idea how to write python scripts tho, I would really appreciate it, thank you. Here is the error screen I get when I try to run the script in Blender 2.49 :

http://i705.photobucket.com/albums/ww58/Bluefurryyspider/error.jpg

Here is the script :

#!BPY
"""
Name: 'Vertex Position store'
Blender: 242
Group: 'Mesh'
Tooltip: 'Restore Vertices to position.'
"""

def Store():
    obs = Object.GetSelected()
    if len(obs)==0:
        Draw.PupMenu("Error%t|No object selected")
    elif obs[0].type!='Mesh':
        Draw.PupMenu("Error%t|Selected object isn't a mesh")
    else:
        me = Mesh.Get(obs[0].getData(True,True))
        editmode = False
        if Window.EditMode():
            editmode = True
            Window.EditMode(0)
        
        if len(me.verts.selected())==0:
            Draw.PupMenu("Error%t|No vertices selected")
        else:
            sel = me.verts.selected()
            store = []
            for i in sel:
                loc = me.verts[i].co
                store.append([i,loc])
            d = {}
            d['locs'] = store
            Blender.Registry.SetKey('StoreVertLoc',d, False)

        if editmode:
            Window.EditMode(1)

def Retrieve():
    d = Registry.GetKey('StoreVertLoc', False)
    if d:
        try:
            stored = d['locs']
        except:
            stored = False
        if not stored:
            Draw.PupMenu("Error%t|Stored information corrupted")
        else:
            obs = Object.GetSelected()
            if len(obs)==0:
                Draw.PupMenu("Error%t|No object selected")
            elif obs[0].type!='Mesh':
                Draw.PupMenu("Error%t|Selected object isn't a mesh")
            else:
                me = Mesh.Get(obs[0].getData(True,True))
                editmode = False
                if Window.EditMode():
                    editmode = True
                    Window.EditMode(0)
        
                for i in stored:
                    me.verts[i[0]].co = i[1]
                    print me.verts[i[0]].co,i[1]
                me.update()
        
                if editmode:
                    Window.EditMode(1)
    else:
        Draw.PupMenu("Error%t|No stored information found")


choice = Draw.PupMenu("Menu%t|Store location|Retrieve location")
if choice == 1:
    Store()
elif choice == 2:
    Retrieve()

At line 8, you’ll need to add two lines

import Blender
from Blender import *

then your code will execute just fine

Thanks Fmehigan, now the script works again, much appreciated.

update** Well adding those lines stopped the python error, the script did run normally , but I just tested it a bit more and when the vertice original positions are added back to the mesh, turns out that they are all over the place for some reason. The script was written for an earlier version of blender, maybe something has changed internally that is no longer supported for some reason.

I did a test with that script just now in Blender 249b.
All seems to work just fine.

Made a object, starting from a cube and extrude a bit.
This i stored.
Moved around a couple of vertices, clicked restore and voila old position of mesh back!

Couple of points to note:
The mesh needs to have exactly the same number of vertices for this to work.
If you change this, this script will no longer work correctly.

Make sure you have the correct object selected.

Good luck with it!

Hmm, I think it was because the mesh had some shape keys on it, that must have somehow messed it up. Works normally on regular meshs. Thanks for the help everyone.