templates

Template approach for a PHP application

Hi everyone, We're in the middle of making a new e-commerce related PHP application and we have come to the point where we have started to think about how we should solve templating for our customers needs. What we would like to do is offer our customers the possibility of uploading/modifying templates to suit their company:s profile....

Using Memcached in Python/Django - questions.

I am starting use Memcached to make my website faster. For constant data in my database I use this: from django.core.cache import cache cache_key = 'regions' regions = cache.get(cache_key) if result is None: """Not Found in Cache""" regions = Regions.objects.all() cache.set(cache_key, regions, 2592000) #(25...

django integrate htmls into templates

hi guys, i have a django 'templating' question if i have in views.py: def cv(request): if request.user.is_authenticated(): cv = OpenCv.objects.filter(created_by=request.user) return render_to_response('cv/cv.html', { 'object_list': cv, }, context_instance=RequestContext(request)) and in cv.html something like: ...

How to reliably specialize template with intptr_t in 32 and 64 bit environments?

I have a template I want to specialize with two int types, one of them plain old int and another one is intptr_t. On 64 bit platform they have different sizes and I can do that with ease but on 32 bit both types are the same and compiler throws an error about redefinition. What can I do to fix it except for disabling one of definitions o...

Use a template parameter in a preprocessor directive?

Is it possible to use a non-type constant template parameter in a preprocessor directive? Here's what I have in mind: template <int DING> struct Foo { enum { DOO = DING }; }; template <typename T> struct Blah { void DoIt() { #if (T::DOO & 0x010) // some code here #endif } }; When I try this ...

How to make compiler work out template class arguments at assigmnet?

Here's the code. Is it possible to make last line work? #include<iostream> using namespace std; template <int X, int Y> class Matrix { int matrix[X][Y]; int x,y; public: Matrix() : x(X), y(Y) {} void print() { cout << "x: " << x << " y: " << y << endl; } }; template < int a, int b, int c> Matrix<a,c> Multiply (Matr...

C++0x class factory with variadic templates problem

I have a class factory where I'm using variadic templates for the c'tor parameters (code below). However, when I attempt to use it, I get compile errors; when I originally wrote it without parameters, it worked fine. Here is the class: template< class Base, typename KeyType, class... Args > class GenericFactory { public: GenericFac...

How do i return a template class from a template function?

How do i pull off something that would make the last commented line compile? How would i have to change this code to make it work? #include<iostream> using namespace std; template <int x> class someclass{ public: int size; int intarr[x]; someclass():size(x){} }; template<int x, int y> int somefunc(someclass<x> A, someclass<y>...

How `is_base_of` works?

Why the following code works? typedef char (&yes)[1]; typedef char (&no)[2]; template <typename B, typename D> struct Host { operator B*() const; operator D*(); }; template <typename B, typename D> struct is_base_of { template <typename T> static yes check(D*, T); static no check(B*, int); static const bool value = sizeo...

how can i add a new price template to magento

hello, how can i add a new price template to the category view (template/catalog/product/list.phtml) without changing the price template that is used in (template/catalog/product/view.phtml)? both files uses the template/catalog/product/price.phtml, but i need a separate price template in template/catalog/product/list.phtml that don't s...

Word 2007 customisation - template based addins vs. custom dlls written in Visual Studio?

I'm planning an upgrade to Word (Office) 2007 and need to decide now which customisation route to take. The current set-up is Office 2000 with templates acting as addins, loading with Word (from the startup folder) to support a lot of functionality - interface with DMS, interface with CRM, user form behaviour and printing to name but a ...

django link to any user profile in social comunity

i am trying to build a virtual comunity, and i have a profile page, and a personal page. In the profile page, one can see only the posts of one user(the user whos profile is checked), in the personal page one can see his posts, plus all the posts he has subscribed to (just like in Facebook) it's a little confusing for me how i can link ...

C++ member function template in derived class, how to call it from base class?

As my prveious question sounded confusing, I think it's best to clearly state what I want to achieve. I have (ignore the inheritance for now and focus on X): class Base {}; class X : public Base { private: double m_double; public: template<class A> friend void state( A& a, const X& x ) { data( a, x.m_double, "m_do...

Bash Templating: How to build configuration files from templates with Bash?

Hello. I'm writting a script to automate creating configuration files for Apache and PHP for my own webserver. I don't want to use any GUIs like CPanel or ISPConfig. I have some templates of Apache and PHP configuration files. Bash script needs to read templates, make variable substitution and output parsed templates into some folder. ...

Derived template override return type of member function C++

I am writing matrix classes. Take a look at this definition: template <typename T, unsigned int dimension_x, unsigned int dimension_y> class generic_matrix { ... generic_matrix<T, dimension_x - 1, dimension_y - 1> minor(unsigned int x, unsigned int y) const { ... } ... } template <typename T, unsigned int dimension> class ...

Elegant way for a recursive C++ template to do something different with the leaf class?

I have a C++ class template that makes an Array of pointers. This also gets typedefed to make Arrays of Arrays and so on: typedef Array<Elem> ElemArray; typedef Array<ElemArray> ElemArrayArray; typedef Array<ElemArrayArray> ElemArrayArrayArray; I would like to be able to set one leaf node from another by copying the poi...

C++ Templates: Convincing self against code bloat

I have heard about code bloats in context of C++ templates. I know that is not the case with modern C++ compilers. But, I want to construct an example and convince myself. Lets say we have a class template< typename T, size_t N > class Array { public: T * data(); private: T elems_[ N ]; }; template< typename T, size_t N > ...

smartif tag not working out correctly

I'm using the smartif tag from this snippet (I'm holding on with regards to upgrading to 1.2) in my template for a certain boolean field like so: {% if payment.extends_membership == "True" %} {% trans "Yes" %} {% else %} {% trans "No" %} {% endif %} But whatever the value of extends_membership I get only No as the output. What ...

Hiding instantiated templates in shared library created with g++

I have a file that contains the following: #include <map> class A {}; void doSomething() { std::map<int, A> m; } When compiled into a shared library with g++, the library contains dynamic symbols for all the methods of std::map<int, A>. Since A is private to this file, there is no possibility that std::map will be instantiated i...

Strange Template error : error C2783: could not deduce template argument

Hi, I have created a simple function with 2 diffrernt template arguments t1, t2 and return type t3. So far no compilation error. But when Itry to call the function from main, I encounter error C2783. I needed to know If the following code is legally ok? If not how is it fixed? please help! template <typename t1, typename t2, typena...