Home  /  RSS  /  RSS Comments  /  RSS for Templates  /  Project Site  /  Enter

Posts in category ‘Templates’.

Thoughts about template system

05/08/08, by artyom ; Posted in: Templates, Framework; 5 comments

After looking how ASP.Net and J2EE work I thought a lot about current template system.

Today, CppCMS template system is dynamic typed. For example in order to render template:

<% template mycontent %>
<p>You have <% number %> of <% something %></p>
<% end %>

I write something like that (not correct code but idea):

map<boost::any> content;

content["something"]=string("orange");‎
content["number"]=10;

template.render(content,output); 

The template is compiled to bytecode and than interpreted in rendering engine. If variable title required it checks its type and renders its content.

Another possible approach it to make is statically typed :

So, I create a view interface for template:

struct mycontent: public content {
  string something;
  int number;
};

And then the above template is compiled to following C++ code:

void mycontent::render()
{
  cout<<"<p>You have "<<number<<" of "<<escape(something)<<"</p>\n";
} 

That is compiled to shared object that I can load dynamically. And render template as following:

auto_ptr<my_content> content(template.get("my_content"));
content->number=10;
content->something="orange";

content->render(output); 
more...

Thread Safe Implementation of GNU gettext

26/04/08, by artyom ; Posted in: Progress, Templates; 0 comments

There is widely available software internationalization tool called GNU gettext. Is is used as base for almost all FOSS software tools. It has binding to almost every language and supports many platforms including Win32.

How does it works? In any place you need to display a string that may potentially show in other language then English you just write:

printf(gettext("Hello World\n"));

And you get the required translation for this string (if available).

In 99% of cases this is good enough. However, as you can see, there is no parameter "target language". It is defined for entry application.

What happends if you need to display this string in different languages? You need to switch locale, and this operation is not thread safe. In most of cases you do not need to do this, because almost all applications will "talk" in single language that user had asked. However this is not the case of web based applications.

Certain web application allow you to display content in several languages: think of government site that should display information in three languages: Hebrew, Arabic and English. So you may need to define the translation per each session you open or use.

So, if you write a multithreaded FastCGI application that supports different languages is signle instance you can’t use gettext.

more...

The Roadmap to The First Beta Version of CppCMS

16/04/08, by artyom ; Posted in: Progress, Storage, Templates, Framework, Cache; 4 comments

After quite a long period of development I had decided to get prepared to first public beta release of CppCMS.

The major components of this blog and the framework I want to introduce in first beta are following:

There are lots of work to do, but CppCMS now looks much mature then before.

more...

New Templates System

23/03/08, by artyom ; Posted in: Progress, Benchmarks, Templates; 7 comments

New templates system was introduces to the CppCMS framework. It is based on ideas of dynamic typed languages inside static typed C++.

The original template system had several problems:

  1. The each template variable was referenced by and integer key that was generated during compilation of templates.
  2. The rendering process required from the developer some kind of activity – update content values according to requests from rendering engine.
  3. The values of the entries where limited to string, integer and boolean values.

In any case, the design of the first template system was just unacceptable, thus new template system was build.

It introduced following features:

Additional features I'm still working on them are:

more...

Next Step - Caching

17/01/08, by artyom ; Posted in: Progress, Templates, Framework, Cache; 5 comments

As we had seen in previous article, the benchmarks had shown an ability of CppCMS to produce about 630 compressed pages per second and an output of about 20Mbit/s. Is this enough?

For most of cases it is… But as we had seen I want to use every cycle of the CPU as smart as I can. Even, if the model I had suggested, was able to show "a prove of concept" there is an important point that was missed: "Why should I create same page so many times?"

Caching

This is the next logical step in the development of high performance web development framework.

First of all we should understand a requirements of the caching system:

  1. Efficiency
  2. Support of "dropping cache on update"
  3. Support of drop the cache by timeout
  4. Work using three models: single process cache, shared cache between processes, shared over the network.
  5. Support of caching on entry page level and single view level as well
  6. Transparent storage of compressed content

Lets describe each one of them:

more...

Pages

Categories

Development

Powered By

3rd Party