Sunday, November 11, 2012

This post is a summary of the past week of work on the Community CSDT website.
The project has been going on for a while, and I recently joined in to help.
Following the great example of Haiqiong's blog on his work
http://csdt-lih9.blogspot.com
I will try to make this a blog that is useful for future developers to read.
The source code for the website is in this (restricted) SVN repository:
https://subversion.hss.rpi.edu/svn/csdt_src
All references to source files in this blog will be relative to that directory

My background is low-level C programming for supercomputers, so I will present a slightly different (inexperienced) perspective on this Python/Java/etc website. As a developer, my priorities are as follows:

  1. understand the code
  2. compile / run the code
  3. improve the code

Understanding

This particular project is somewhat lacking in resource for understanding the code. What I have done so far is to read through most of the Python source code, which I understood more after reading this
which describes the overall way that the Pyramid framework calls Python code based on which URL is requested.

The Community CSDT website is built as follows: the Python Pyramid framework is the core of the system, serving content based on the Python classes defined. The user information is stored in a MySQL database, and the main content being served is the actual CSDT Java applets.

Compiling and Running

I was able to compile and run the website on my laptop using the instructions at
Community/docs/installation/pyramid.installation.txt
Well... almost. I ran into a couple of issues (which I later found that Haiqiong also ran into and mentioned in the blog). I added comments to the installation text file so that future developers do not need to read blogs to compile their code.
Right now, the setup I have on my laptop does not show the thumbnails or applets, I think there is still some copying I have to do from pCSDT to Community.

Improving the Code

There were several issues I explored before even compiling the code for myself.
Presenting them will serve as a work log and a depth-first explanation of how the code works.

First, the website allows new users to register and has an email-confirmation system. That means registration is broken into two steps: ask the user for her name and email, send a link for part 2 to the email provided, then when the link is clicked continue with part 2. To be more precise, once the user has provided a name and email, that information is encrypted into a long string which becomes the query in the URL for part 2. This URL is long, so it is then shortened using TinyURL.
There were reports of this TinyURL not working, here is what I observed:
  • The very first time I tried to register, clicking the TinyURL brought me to a page saying TinyURL couldn't find the destination.
  • I got the true URL from the log file of the web server, and pasted that into my browser. that worked.
  • I pasted the true URL into the TinyURL website. This returned me the same TinyURL as before, which means it was registered the first time. Now following the TinyURL works
  • After that, I tried to reproduce the failure again but couldn't. I registered with different names and emails from different computers.
So that issue is on hold until it can be replicated again. One solution would be to avoid TinyURL altogether. We use it because the true URL is long, which is because the name and email are encoded in the query string. Maybe we can keep the name and email as session data (in a cookie or in the MySQL database), and just send a URL with some kind of session id as the email confirmation.

Second, when viewing a user's list of projects, the Edit and Delete buttons just link to the home page instead of doing anything. Simple enough, they have not been implemented. the links in 
Community/src/community_csdt/community_csdt/templates/user.profile.mako:85
should be changed when there is code for editing and deleting.

Third, after a project is uploaded, we would like users to be taken back to their profile page instead of the home page. This should be easy to do by simply changing one line:
Community/src/community_csdt/community_csdt/templates/uploaded.mako:16

Now What?

I have an almost complete setup on my laptop, so I will try to solve some of the issues mentioned and then push them to the test and development servers before next Wednesday.

No comments:

Post a Comment