I started out populating the the lua environment where the scripts will be executed using the lua C api. I am pushing a global lua table mk for the time being which would contain all the variables and functions that I am currently implementing.I have a function mk.print that will buffer everything and print to a static file. Currently we will have 3 tables under monkey, config, request and response. The request table will all the request headers in native lua types and the response table will have the defaults, which when modified read back to set response headers.

request and config table have been implemented, response is yet to be implemented and and the already implemented tables could use some polish.

I have also added an example lua script which shows how the current api looks like.

Next Week

  • Finish up the environment preparation
  • Start Working on thread safe lua execution

CODE: I moved the plugin code to a new repo github

This week started with the aim of setting up a unit testing framework for the plugin and do test driven development from now on wards. My configure function is working and I wanted to add a few tests so that everything could be tested automatically.I started out with learning how to use CUnit and made some basic tests. I got sick in between and had to take couple of days off in between and lost my flow. I also ran into complications as I wasn’t sure whether I could mock everything from the monkey api for testing. I am currently stuck on how to mock the monkey api for unit testing as I didn’t want to compile the whole repository for unit testing the plugin.

So I put the unit testing on hold for a while and started working on the environment preparation steps for running lua scripts. Unit testing these functions where easier to implement as I wont require session request. I have wrapped some of the config into a lua table that will be injected into the lua environment and the custom mk_print will be used to populate a buffer that will be used to set up the return the values to the user.

Plan for next week: Clean up and consolidate all the work done till now so I can follow TDD and go at a faster pace from now on wards.

  • Catch up to the schedule and figure out a way to setup unit testing properly
  • finish the api for returning results

I am slightly behind schedule as I rabbit holed a bit this week and also had to stay away from work due to some health issues.

code:github

I am currently re factoring the code so that it, could be tested easily.

I was having my university exams during the last two weeks of community bonding period and couldn’t dedicate as much time as I would have liked as my schedule became a little tight.I also lost a bit of time as I was moving and unfortunately lost my glasses. So my exams are finally over and I am fully focused on the coding work now.

I started of the week by going through the lua programming manual and few applications of the Lua C api. I made a few sample programs to better understand the stack based api.I started working on the plugin and made a basic configuration reader for the plugin which is very similar to the CGI plugin. The scaffolding of the plugin is in place and I can get into building a basic version the next week.

Most of my time this week was spend in reading code and identifying functions and data that should be exposed through the lua scripting framework. I haven’t finalized the api yet and will have to discuss with Jorge about the same. I have currently decided up on wrapping certain data structures like the server config structure, the session request structure and a few others and injecting them as globals.Then they have to be read back. Another possible implementation could be using explicit function calls from the lua scripts for communication.

Work for next week

  • Complete a basic version of the plugin.
  • Draft the api and start the implementation

code: https://github.com/diadara/monkey/commits/lua-exp

I applied for GSoC this year also and fortunately the folks at monkey-project liked my proposal. My original proposal was to work on a dashboard for Raspberry Pi using the monkey webserver and the duda i/o framework built over it, however my mentors asked me whether I would be interested in working with them on another project. I was more than happy to say yes to them as this represented a more challenging project which I must admit, a little intimidating as I haven’t had much experience in system programming apart from making some system calls and the server client programs you write in your computer networks course.

The project I will be working on involves creating a Lua plugin for the monkey http server and also a memcached plugin for monkey-project.

Lua is an embeddable scripting language that can be used to add some scripting capabilities to the monkey server. In addition to the usual dynamic content creation, the plugin should be also able to do some administrative tasks with the monkey server and also collect statistics on the various api calls.The second part of the project will be to integrate this functionality into duda as a duda package and design a API for it.

The second project to be completed is developing a memcached plugin for monkey that can can interface application with the popular distributed in memory key value store database.

Last year was full of ups and downs and I can honestly say that I am a changed man.

alt text

You feel you’ve been rehabilitated?

Red: Yes, sir. Absolutely. I’ve learned my lesson. I can honestly say I’m a changed man. I’m no longer a danger to society. That’s the God’s honest truth. No doubt about it.

I have burnt a lot of bridges this year and created a few. I have no regrets. One of the highlights of 2013 has been getting selected for http://www.google-melange.com/gsoc/homepage/google/gsoc2013. I had worked a lot to get selected and my acads suffered a lot because of that. The whole affair proved to me that you could probably do anything given time if you genuinely want to do it. I was also disappointed a bit with the whole affair as I found myself losing interest after sometime. I can’t blame anything for it except my short attention span. In the end I barely scraped through. Again I did manage to learn a lot of stuff like python packaging, writing documentation and some related stuff.

I have tried to learn at least half a dozen distinct languages this year and picked up a lot of things. The lack of mastery is the only thing that worries me. I have made it to point to focus on making things rather than learning stuff from now on. Let’s seen how that pans out.

Another important change this year has been, switching to Emacs. One thing I have noticed is how Emacs encourages it’s users to look under that hood and hack stuff. I you don’t understand a particular key binding or function just hit C-h k or C-h f and you will get the docs with a link to the source. I am sure this philosophy of everything is hackable will flow into the users day to day work flow.

Also I managed to read a few books last year. I certainly plan to increase my book consumption the coming year. Last year was pretty disappointing with respect to TV. Breaking Bad and Homeland were the only exceptions. Person of interest shown in intervals and that was enough to keep me coming back every week though the lack of alternatives must have been the main reason.

This year I had signed up for a number of MOOCs and only managed to complete one. The one I managed to complete was BerkleyX’s SaSS 1. It’s a pretty challenging course If you haven’t done any rails before.I learned a lot. I had signed up for the Scala course by Martin Oderski, the programming languages course in Coursera, Andrew NG’s ML course, history of rock course on coursera, Georgia Tech’s Computational Finance and a few others. I had left them due to the lack of time. Come to think of it I could have completed a couple if I had concentrated my efforts. One more thing to change.

This year also saw Real Madrid and Arsenal both not winning anything. Hope both do well this year.

So apart from the usual resolutions, the ones I hope to keep are

  • read more.
  • code more.
  • complete some MOOCs(I have already signed up for a few)
  • contribute more to open-source.
  • master something.

For the past couple of weeks I have been mainly fixing errors and other issues that with the already ported packages caused mainly due to the reorganizing and renaming of their dependencies. Normalizer module will be used by all the modules instead of silpa_common normalizer.

Another issue was that the template files had to renamed to reflect the change in module names as the framework expects the template to be of the same name as the package name.This behavior has to be changed as packages may have more than one template or another cases where the template name has to be different from the package name. A possible solution is adding the template name in the code itself But this will require changes in the way modules are required.

I have also re-organized some of the tests and added the test suite to setup.py so that tests could be more easily rub with a python setup.py testcommand.

Apart from this I have partially ported indiccallendar (python backend working though the module is not fully finished yet ).I was also working on flask-webfonts.I have implemented the yaml based configuration for setting up font repositories. I am now rewriting the interface using jquery.webfonts extension.Jquery webfonts expects data to be fed in a certain format which is slightly different from the flask webfonts currently available api. It was also planned to reduce the number of fields that has to be set manually in the font configuration using some sort of mechanism to extract metadata from the fonts files. I am yet to figure out completely how to it effectively as a single font can come in multiple formats and may create conflicts in some cases.

Webfonts flask extension is taking longer than expected partly because of my college work and also since I had to rewrite some parts of it multiple times.

Present status:

  • Api completed and usable with user supplied fonts
  • Changed the interface from jinja2 to a http api front end
  • Configurable urls and folders.

TODO:

  • documentation and testing
  • clean up the api
  • more features to the interface

I have been working on restructuring the webfonts flask extension to make it more user friendly and general purpose. I am rewriting the routes using method views to make the extension more compact and extensible. I am sticking with using the main app static folder for the fonts, and the user will have to pass a dictionary with the font list and locations of the font files to initialize the extension.

The main objectives completed this week were:

  • rewrite the extension using view classes
  • improve the api so that routes and folder structures could be customized
  • create a bare bones template that can be shipped with the extension

I am having a little trouble organizing everything so that the extension remains modular.I was making some circular imports which can break in some cases. I have been going through source code of some of the larger extensions that provide interfaces like flask-dashed and flask-admin which uses class bsed views . I hope to release a working version in a couple of days and move into testing and documentation.

This week I started work on flask webfonts extension.I use mitsuhiko’s flask-extension-wizard for the scaffolding and added the webfonts module as blueprint. The css api is working smoothly and and I have started working on the gallery interface. The interface I made was based on twitter bootstrap and used some of the javascript components. Also there are a few bugs and the code is somewhat messy, so I will be rewriting it.

Also the current version of the extension comes with fonts included. I am trying to make it possible for users to add fonts to the repository. Currently this requires the user to use a folder inside the static folder of the main app. There are ways around this to serve fonts from any folder but these methods have security issues.

The extension also has to handle factory pattern apps. The extension at it’s current state can handle this but advanced features of the app object does not work. I have run into an issue with relative paths for specifying the font directory. Next objective will be to add all these missing features to the extension.

You can follow the development on github

Past week I had been trying to get the webfont module working properly and had some difficulty setting things up. There was an issue with the app returning different mime-types from localhost and openshift servers. Well it turn’s out that I was setting the mime-type with response.headers[‘content-type’] , now the response object has a built in mimetype method to set the mimetype .I spent an awful lot of time to figure out this reinventing the wheel by manually setting the headers.

Rest of the week I worked on cleaning up the ui. The bootstrap slider used for the slider looks brilliant but the controls were broken, seems like the author is not very active and found the component to be a bit buggy and needed a few hacks to get it working. I found a fork of the project with some of the bugs fixed. I am considering migrating to this version of the plugin.

I also spend some time getting familiar with the testing using unittest module as I have to add tests to the packages. I am not very familiar with all the functions of the ported packages so I will focus on creating very simple tests and later on expand the test coverage with the help of people more familiar with the respective languages and functions of all the modules.

I had a discussion with my mentors on how this module should be added to silpa as this module does a very specialized operation, that is serving fonts using silpa-flask. Since it is not reusable, there’s no point in keeping it as a standalone python package. Another option was to add the module to silpa-flask repository itself. Again this defeats the purpose of separation of silpa modules in silpa-flask. Copyninja suggested that this can be made into a generic flask extension which can be used in any flask application to add webfont support. So I spent some reading stuff on flask extensions.

The extension will have to keep some high level of code quality to be accepted as an official approved extension. I believe this will be a very useful extension and can come in handy in a variety of situations. So I made an initial evaluation for this and it looks like I will have to write the extension from scratch however the template developed can be reused. I have started working on the flask extension and hopefully I can finish it this week itself.