Dec
03
2010
Last week we had our first formal Freelance Seminar in Bulgaria. After few conferences and public lectures we did a full-day seminar on freelance. The Freelance Lodge with Mytime.bg cooperated with Superhosting.bg, MiNDS and CCB for that event to happend.
Video materials are expected, more info is available here and here. However, we hope that freelancers all around the country will join our community and be responsible enough to help other events and workshops happen as well.
Nov
13
2010
I'm really fond of CakePHP's principles, but I'm too tired of its i18n features. For some reason internationalization, although one of the really major requirements for every framework or CMS, is implemented poorly in most of the systems I've worked with. Django had few disadvantages (but few strong points as well) with its django-multilingual, and here it comes Cake with its toolkit for multilingual applications.
Comparing with few Java frameworks + CodeIgniter, I'm pretty aware of using locale-based apps with few languages for dynamic content. It's ugly as hell most of the times.
The beauty of Cake is mostly its 'convention over configuration' and dynamic admin panel generation. Admin panel is pretty neat, although there is no CMS-alike functionality and one should translate/adapt the admin for a project every single time. This is a problem that savant is taking care of, creating a multi-functional and reusable administrative panel. However, nobody has ever ...Dive in
Oct
10
2010
This week has been inspired by the power ot Java (this is how a movie like Javatar would probably start).
Offtopic
Anyway, I'm glad that I attended Java2Days event this year. It's been my second Java2Days event including the one in Oct 2009 (which I described in my Bulgarian blog with auto Google translation in EN). After few years being highly coupled with Java, I decided to do some freelance which lasts for about 2 years now. Meanwhile in addition to Java I've studied plenty of new technologies - PHP and Python in depth, different frameworks down there, few abstract programming structures for specific projects, set-top boxes etc. This makes me feel even more proud being a participant of such an event: now I am able to truly compare scripting languages and Java, dynamic against static typing in different cases - small and medium size projects, enterprise applications, distributed systems.
Also, as a ...Dive in
Sep
30
2010
I've been working with Linux for a couple of years but I'm not sysadmin so I use the parts of the system that I need at work. Mostly different activities with user interface interactions (which is similar to Windows behavior). However working on remote servers, comparing data, transfering and managing projects requires ssh-ing, some file management, archiving, searching in file system, filtering data, hiding folders etc. Here there are few of the tips I've used in the past days and I find useful:
Create/Extract archive ('z' option could be added as well if working with tar.gz files):
tar cvf archive.tar directory
tar xvf archive.tar
Print/list the content of a tar archive:
tar -tvf archive.tar
Create an archive from a SVN-based project excluding SVN:
tar --exclude=.svn -c -f archive.tar projectdirectory
Works for copying an SVN directory with rsync without .svn subdirectories:
rsync --exclude=.svn -r somedirectory somenewplace
Find differences between 2 directories with changes in each file:
diff -r directory1 directory2
Print only file names ...Dive in
Sep
25
2010
It's been my first week using Croogo - a CMS platform based on CakePHP and created by the Bangladesh developer Fahad Heylaal. Recently I've been looking for a next level platform in order to decrease development time and reduce wasting time for writing standard things from scratch such as menus, user controls (Auth+ACL), multilingual options etc. What Croogo does is delivering all this in a way upper lever.
Croogo itself works out some general concepts in a way that we know from other popular systems. Overall look & feel in admin panel seems like the one that we've seen in WordPress. The node-based content (with ability to create new types from the admin) is a well known practice in Drupal - CCK. The core is, of course, CakePHP. I'm quite sure I could find more similar characteristics but the point is that the system is stable enough and flexible as well ...Dive in
Sep
12
2010
In a CakePHP application we could define an intermediate abstraction of a controller called AppController. The concept is having a Controller class defined by Cake core, writing controllers for our project and defining app_controller.php file for our common functions repeated in every controller.
In this case we usually use beforeFilter or beforeRender method in AppController in order to define some data to be transferred automatically in every controller. More about app_controller and callback functions.
When a variable is set in beforeFilter, it could be used with it's name later in CakePHP views. For example:
$this->set('products', array('P1' => 'Pizza', 'P2' => 'Water'));
Any view later:
<?php echo $products['P1']; ?>
But that variable could not be accessed directly in a controller function. In this case we could use viewVars array in order to access beforeFilter set variable in other controller method, which solves our problem:
function test() {
$products = $this->viewVars['products'];
$product_1 = $products['P1'];
}
Sep
09
2010
Turns out that there are plenty of useful features in the Django admin that I never thought about.
The other day I found the last task of a project of mine was adding the "Forgotten password" feature. It's basically a standard task included in every users-related project, but the whole process requires few interactions:
clicking 'forgotten password' link
writing user email where the password should be send to
verifying email against users database
sending confirmation link
confirming link
choosing password
resetting password
The whole 7-steps list (with UI and backend communications) could be boring and time wasting (usually).
That's where Django's templates and integrated behavior comes as a super hero.
Copy all necessary templates from your Django installation
There are few templates that you need to copy from your Django installation. You can find them in your DJANGO_PATH/contrib/admin/templates/registration. You can copy all password-related templates to your templates directory in admin/registration folder.
Some URL paths have to be added to your urls.py file. That's a ...Dive in
Aug
14
2010
If you use the django-multilingual module for multilingual content, you need to add a translation for every language your entity could be seen through. Otherwise you get 'None' as a title (which is way too blurry and quite indescribable). Thanks to my colleague and friend lpetrov I found a way to pass through this limitation and print any possible translation if the current one is not available.
I've added a translation.py file in my project which I import in all my apps when necessary. Here there is the code:
def get_local_str_or_other(obj, field_name):
result = getattr(obj, field_name)
if result:
return result
else:
field_for_search = field_name + "_"
translations = [getattr(obj, field_for_search + lang[0].replace("-","_")) for lang in settings.LANGUAGES]
...Dive in
Aug
11
2010
I found a great presentation on Django debugging from Simon Willison.
It's a presentation on "Django 101 in troubleshooting". You could find information how to address any errors from the error pages that django throws away, how to follow stack traces and how to debug information in variety of ways.
Simon pays attention to the basic and the core of all debugging tools - the console. Every single output pass through the console itself so it is the mother of all outputs. Other popular options is the python debugger under the pdb package.
I personally do like django-debug-toolbar for my apps. It is quite useful for taking care of the HTTP requests and response, passed variables across the website and so on. You could check the number of SQL queries and the load time of your website. Another important feature is printing the list of all templates used for rendering a web page. ...Dive in
Aug
09
2010
Django is a popular web framework written in Python that provides dynamic generated content and allows rapid development for different systems in the Internet. It provides a great interface to other products (via web services), gives ability to design a scalable application and most important, lies on a powerful language as Python (in other words, what you could do in Python, you could somehow reuse it in Django either by a component or by defining a custom logic down there).
In my experience two of the most important things in a web application (no matter the framework, system and language) are the user management and multilingual support. Django has an Auth module that does most of the things you need - provide users and groups, powerful permission API for each model and action down there and many methods to be overriden from the framework to fine tune the filtering if needed. ...Dive in