Sunday, June 13, 2010

GSoC 2010 Melange Testing Project: Week 3 of the Coding Period

Last week, I finally got Django test client working with the help of Sverre (my mentor). In this week, however, another problem arose. For some urls, e.g. /cron/poke, the response returned by the test client is a Django http response object; for other urls, e.g. /user/show/a_user, however, the response is a dict. After failing to figure out what had caused the problem, I asked Sverre for help again. Sverre suggested that it might be due to the stubout code (pymox) in tests/app/soc/views/models/test_base.py. After I commented the code, however, the problem still did not go away. Later, Sverre found that the problem was due to that the fact that the stubout in tests/app/soc/modules/ghop/views/models/test_task.py has not been unset. So, he added the unset code to tearDown methods and also helped me reviewed/improved and merged my code of refactoring the stubout code into a helper class. Thank you very much, Sverre!

After solving these problems, I started to do view tests for soc.views.models.user using Django test client. I have almost finished it. Yesterday, I pushed the code into my online clone. Today, I asked Sverre to have a quick look to see if it is alright and he was satisfied with it. Though I am still behind my original schedule, I am confident that I can catch up soon. This is because I have solved all major obstructions and have finished adding tests for one logic (base) and one view (user) so that I can follow similar patterns to add tests for other logic and views very quickly.

This week, I also came across the trace module of python when I tried to find another problem I met. It can be used either in command line with python -m option or in your program. This module save you time to code a call back function for sys.settrace by offering some common functions. One useful function is to trace the execution flow of your program. It traces every statement, so be aware the output could be quite large. For example, the output of tracing a single statement of Django test client in Melange testing environment is more than 100MB. Another disadvantage is that the output only shows the module name without package path which could confuse you when you have many modules with the same name or you have a big project and do not know the package of every module. Another useful function is to trace calls. The output of this one is quite small compared with the first function and also has full package path. This function, however, is not perfect either. The problem is that the calling functions are ordered by their module name rather than by their calling order which is arguably more useful. And you have no options to change the order. Besides, you can only use it in command line.

Document Editor: Week 3

This week I worked on revision implementation. As proposed by Lennard I tried to refactor soc.models.work.Work, but found out that Work is also the base class for Quiz, Proposal, Documentation, Question and Survey. Daniel also proposed to implement revisions as three different models. That's why I decided to leave Work for models that doesn't support revisions and implement separate revision-related models.

In a couple of days I plan to implement logic for revisable models, refactor create function and implement view to list all the revisions.

Friday, June 11, 2010

Coding Week 3

A third week of coding has gone by. The User Page status is at an "almost-there" status. The latest is uploaded to my GAE instance.
To have a user page, all users must have role assigned to them such as student,mentor,org_admin or program_admin. Only then do they get the option to Create a User Page on their sidebar. On the current instance, all users can Register as Student and then go ahead to create the User Pages.
However, there are still some things left to wind up with regards to User Pages, before I move onto extensive testing of this feature and then move on Calendars, which I have to start this week according to my timeline!

Things left to wind up:
  • listing all User Pages
  • Pulling present/past project data for student/mentors/org_admins
  • getting images api to upload profile picture(currently using blobstore to upload, but the picture doesn't seem to show up)
  • polishing CSS and layout of User pages
Upcoming Week:
  • Finish up with User Pages feature and start on testing.
  • Start coding work on Calendars

Sunday, June 6, 2010

GSoC 2010 Melange Testing Project: Week 2 of the Coding Period

In this week, I had planned to add test cases for app.soc.views.models.base.View as well as app.soc.logic.models.User.Logic and app.soc.views.models.User.View, app.soc.logic.models.Role.Logic and app.soc.views.models.Role.View.

As I mentioned in my project proposal, I want to use Django test client which acts as a dummy Web browser to test views of Melange because of its ease of use and good integration with Django (no surprise since it was developed by the Django team). So, I first tried to get Django test client working.

After many attempts, however, I still could not make it work. Then, I found that I could not even run Melange locally suddenly due to the error (google.appengine.api.yaml_errors.EmptyConfigurationFile). I first tired to solve the problem by checking the tracktrace and code. Unfortunately, however, I could not find the problem. I thought that I might have accidentally changed or removed some important files. So, I rebuilt my local Melange but it still did not work. I also tried to re-clone and rebuild another Melange, but it was still in a vain. At that time, I realized that I had to fall back on my last resort, asking my mentor Sverre :-) . Awesomely, Sverre found that the problem was due to the corrupted .appcfg_nag file and he then solved the problem by removing it.

After this problem was solved, I tried the test client again. However, it still did not work. So, I asked Sverre again and found that it is because I had used the trailing slash at the end of the url following Django's tradition while Melange uses a url pattern without the trailing slash. Finally, Django test client works!!! Hope I had asked Sverre earlier :-).

Because of these problems I encountered, I have not finished this week's work as planned. Fortunately, however, I have got Django test client working. In the next week, I will try to speed up my work, finish this week's work as soon as possible and then start next week's work load.

Saturday, June 5, 2010

GSoC 2010 Data Seeder - Data providers

This week was all about implementing data providers. I haven't got much time to work this week, it was the last week of my university semester and I had a lot of unfinished work to... finish, and also had to prepare for a Google internship interview.

What I've done so far includes the base classes for data providers and implementations for string data providers. Other providers should be easier to implement now that I have a functioning base, I hope I can finish them over the weekend as I've got a bit more time on my hands.

After an IRC meeting with Mario, we have decided that the AJAX API needs some refactoring which I will update soon.

Friday, June 4, 2010

Coding Week 2

The week 2 of coding has gone by. And I have made progress with my code.
I have written the View and templates for the User Page with most of the functions such as "view_page", "edit_userpage", "create_userpage", "view_calendar" etc.

The prototype of the User Pages, Calendars up on my GAE, plus I have created some forms using Melange's inbuilt forms framework for editing data in the User Pages using the base.py View methods such as create, edit, editPost, editGet, etc.

There are some issues with the creation/saving of the forms and entity data which still need to be resolved. Aiming to resolve it before the weekend is over.

Finally, I need to incorporate the ListView for User Page entities using the list functions in Melange's base.py View framework.

Next week:
  • I should have completed User Page functionality, and should have my code reviewed by my mentor, before pushing the changes to my clone.
  • I should update project wiki with a complete timeline, taking into account my current progress on the project.
  • I should start working on the Calendars feature.

Sunday, May 30, 2010

New Document Editor. First week of coding.

Strangely, there were not much coding this week :) All I've created was same kind of "Hello, world" app for Django-GAE. But now I got a good idea about how these things actually work together.

Most of the time was spent on studying the GAE datastore. I had to get a firm grip on this topic before hacking out Melange's models. First of all, I've looked through a wonderful book on GAE. The architecture of the datastore seemed quite unusual compared to the Django ORM. But it definitely has some cool features like associativity and Expando (sounds great!) class.

My main concern is the architecture of the revision control for Melange. There are two main approaches:
  1. Add fields that store revision information to the existing models and convert the whole bunch of existing documents.
  2. Create model that stores information about revisions and link existing entities to it.
I hope this issue to be resolved soon for me to start actual coding.

P.S. Here is the thread in the development list.