IT

Disabling users instead of deleting.

I came across a use case where I needed to disable users without actually deleting them so a user could continue to be associated with their data and reinstated at a later date.

At first I thought that I’d need to roll my own Identity Provider but I came up with a method that is slightly easier to implement.

I added a BoolCol to the auto-generated TurboGears User Class:

Class User(SQLObject):
    ...
    disabled = BoolCol(default=False)
    ...

I then changed the classmethod that SOProvider uses to get the user from the database to raise an SQLObjectNotFound when a user’s “deleted” flag is set to True.

@classmethod
def by_user_name(self, text):
    try:
        u = self.by_email_address(text)
    except SQLObjectNotFound:
        raise
    if u.disabled:
        raise SQLObjectNotFound
    else:
        return u

Note that this classmethod has also been modified to return users by email address.

This way user can effectively be disabled as they can no longer log in successfully. It’s cheating outrageously because raising an SQLObjectNotFound exception is clearly lying to the SOProvider, but it works effectively.

IT
TurboGears

Comments (4)

Permalink

Photorealistic Vector Art

It’s hard to believe that these images are vector art and not actual photos.

Asides
General
IT

Comments Off

Permalink

Del.icio.us, Pukka and (more) AppleScript

Recently I’ve become much enamoured with AppleScript. All those little things you wish you could simplify or do automatically can be made a reality with this wonderful tool.

I’ve also started using del.icio.us after much procrastinating; I’ve been meaning to store and tag my bookmarks somewhere other than on my browser toolbar as they are starting to get a little unmanageable.

In my quest to further remove my need for the mouse, I looked into a handy app to add to my del.icio.us bookmarks straight from Safari. I couldn’t quite find what I was looking for. I did find a very simple but very neat app for creating bookmarks which can be scripted using AppleScript: Pukka.

Continue Reading »

IT
Mac

Comments (7)

Permalink

Custom dispatcher in CherryPy

Despite my previous success in using Routes with CherryPy (partially at least… I never could get URL generation to work properly), I’ve been looking into nice, easy, clean ways to use the default method as a custom dispatcher for a given controller.

For example, the app I’m currently working on is a simple ticket system to handle support requests from clients. I want to be able to access tickets in a semi-RESTful manner:

/ticket/[ticket id]/[action]

This might have been made easier on myself if I’d gone for the URL structure below as all of CherryPy’s methods now allow for positional parameters.

/ticket/[action]/[ticket id]

However, that structure doesn’t work logically in my head and I’m a stickler for detail.

Continue Reading »

IT
TurboGears

Comments (1)

Permalink

Mail, Applescript and Quicksilver Triggers

This morning was my first foray into the world of Applescript, and it was surprisingly painless. My basic need was to have a key shortcut for each of three tasks that I do continuously in Mail in a semi-GTD fashion:

  • Mark a message as Unread and move it to my @Action folder
  • Mark a message as Unread and move it to my @Hold folder
  • Move a message to my @Archive folder

After a little research I found various scripts that did small parts of these tasks from which I gleaned my first working scripts for Mail.app.

Continue Reading »

IT
Mac

Comments (4)

Permalink

Hosted Gmail

I’ve just got hold of my invite for Hosted Gmail, and it’s made me very happy. Not only does it give me the awesome Gmail web interface but, as an added bonus, my mail.app doesn’t have to keep asking me which mail server to use when I’m in different locations. Normally I have to fill this in with the mail server address of the ISP I’m currently connected to.

I’ll be giving it a thrashing as soon as my MX records have updated properly and I’ll post an update.

General
IT

Comments Off

Permalink