Rick Hurst Web Developer in Bristol, UK

Menu

Category: classic asp

OK maybe this Zope object database makes sense now..

I’ve just made a breakthrough in my perception of Zope and its object database. Despite the fact I have been working with Plone for over three years i’ve always struggled to shift my way of thinking away from relational databases and SQL queries, due to my previous experience of building sites and applications mainly with asp (classic) and php, hooked up to a relational database.
So what caused my Eureka moment? A combination of:-

a. Not developing with plone for a while

Since going it alone I have been doing an eclectic mix of work for different agencies and companies, who all have their own pet technologies and ways of working (so far I have slotted straight into them all with a minimum of fuss- Jack-of-all-trades at your service! Except Perl. I had to turn that one down).

b. Doing a bit of old school Zope

From the moment I started with plone, when I haven’t been skinning/ templating, I have worked almost entirely with Archetypes. Archetypes generates forms for you and all the other “magic” – some lovely helpful magic, some dark voodoo that shouldn’t be spoken aloud in front of non-programmers (like me). This means that with Zope I never learned how to do a typical build a form that posts to script, script writes to database, script pulls out of database and renders it back in the page/form routine, which is usually the first thing I would learn with any other web technology/scripting language.

c. Starting to think in objects

Once again, this had more to do with not working with zope for a while. Before zope I only had a basic understanding of objects and only used them where I was forced to because I was working with someone elses code. I would encapsulate functionality by sticking a load of php/asp functions in an include file with a meaningful name, but I never took the step of wrapping them up in a class and treating the piece of functionality as an object. Something must have sunken in during my Zope years, because now I find it difficult to not think of something as an object.

So, i’m rambling – what exactly was my moment of clarity? It was simply adding a few extra fields (wait – properties) to portal_memberdata and personalize_form in Plone. I went off searching for the python script that would take the data out of the database and pump it into an object for me to use again in a page template – but of course, being stored in the ZODB, it already was an object. Z.O.D.B. Zope Object DataBase – geddit?

So in summary, I think anyone new to plone development could do with learning things the “old” way before they move onto developing with Archetypes – purely for the sake of demystifying the ZODB, especially if like me you come from a php/asp background and have trouble understanding why you would use an object database rather than a relational database.

Next stop Zope 3 – I’ve read several reports about the large amount of boiler plate code needed to create something fairly simple with Zope 3, and a few solutions to speed up the process, but I will definitely make sure to understand how it is done “manually” before attempting to move onto using any shortcuts this time.

IIS, basic authentication, permissions and include file

Occasionally I have a problem to solve that burns some serious time and makes me doubt my ability in my chosen field, and this was one of them until a “eureka” moment a few minutes ago..

I had been struggling with using basic authentication (over https) with IIS to lock down access to a particular (classic) asp script. Not really an expert in windows permissions, I had been trying all sorts of combinations of folder and file permissions to get this to work, but I was getting a permission denied error whenever I tried to login using an account I had set up. After far too long and realising that I could get it to work with a plain text file, but not my asp file, I realised that my asp script had a load of include files which sat in a different folder, and I needed to give execute permissions for my trusted user to these too.

If only it hadn’t taken me something like eight hours to work that out, I might just be in bed now!

Access Compact and Despair Utility

An asp/ MS Access web app of mine suddenly stopped working, and was throwing an error:-

Microsoft JET Database Engine error ‘80004005’

The Microsoft Jet database engine cannot open the file ‘C:foobar.mdb’. It is already opened exclusively by another user, or you need permission to view its data.

I knew that it wasn’t opened by another user, so it must be related to the permissions. I remembered the previous day I had run “compact and repair” in the Access GUI to bring the database size down. Running this as administrator via the GUI in situ on the server seems to remove the permissions for the IUSR_(your server name) account. You can add permissions back in for that user via the security tab for the file (if you have access to the server gui).

One way to avoid this is to run the compact and repair procedure from an asp script like this one. This seems to do the trick without breaking anything

MS Access gets protective over its relationships

When building things from scratch with ASP/Access, I never use any of the “advanced” features of access, such as relationships, as I don’t need the Access GUI to manage this stuff for me, as the logic and relationships are managed by the ASP code, and SQL queries instead. This means that I often forget these things are in place when I extend someone elses web app – I had a full-on fist fight with an Access database that wouldn’t let me delete records from a table because it contained relationships (with itself). In the end I had to go into the access GUI and delete the relationships altogether for that table. Obviously now i’m wondering what the knock-on effects will be…

Frameworks make you forget

I’ve recently being doing a bit of “old school” web development, manually creating HTML forms and (classic ASP) scripts to validate and process the forms. I was surprised at how much I have forgotten of my basic HTML, since I have been using a framework (namely archetypes in plone) to do all the form generation, validation and processing for the last couple of years. I even had to go and view some source code on another site to remind me of the correct syntax for an HTML select element (form drop-down).

Whilst doing things manually is very laborious, it does give me a feeling of control back, and I am confident about debugging and modification in a way that I miss when relying on a framework. Wouldn’t want to go back to this form of development for any large projects though!