def generate_module_config(self):
        module_config_cont = '''
<?php

$&router = array(
    'routes' => array(
        '$plugin_key' => array(
            'route' => '/$plugin_key[/]*:op[/]*:id[/]*',
            'target' => array('cl' => '$plugin_key'),
            'methods' => array('GET', 'POST'),
            'filters' => array(
                    'op' => '([a-zA-Z][a-zA-Z0-9_-]*)',
                    'id' => '([0-9]*)',
            ),
        ),
    ),
);
'''
        tpl = TemplateIgnoreInvalid(module_config_cont)
        module_config_cont = tpl.substitute({'plugin_key': self.plugin_key})
        module_config_cont = module_config_cont.replace("$&", "$")

        config_folder_path = os.path.join(self.plugin_path, "config")
        if not os.path.exists(config_folder_path):
            os.makedirs(config_folder_path, 0755)
        if os.path.exists(config_folder_path):
            module_config_file_path = os.path.join(config_folder_path, 'module.config.php')
            with open(module_config_file_path, 'w') as mc_file:
                mc_file.write(module_config_cont)
            local_db_path = os.path.join(config_folder_path, "local_db.php")
            local_const_path = os.path.join(config_folder_path, "local.php")

            with open(local_db_path, "w") as ldb_file:
                ldb_file.write("<?php\n\n//write the database related constants here")

            with open(local_const_path, "w") as lconst_file:
                lconst_file.write("<?php\n\n//moduel constants go here")
    def generate_controller(self):
        controller_mk = '''
<?php

class $controller_class extends PluginController{
    protected $&plugin_name = '$pname';

    function __construct(){
        parent::__construct();
    }

    public function index(){
        $&tpl = 'index.tpl';
        //the body of the function here
        $&items = array();

        $&this->assign('items', $&items);
        $&this->assign('error_msg', error_msg());
        $&this->set_form_redir('index_submit');
        $&this->display($&tpl);
    }

    public function list_all_submit(){
        //process data here
        return $&this->mk_redir('index');
    }
}
'''
        tpl = TemplateIgnoreInvalid(controller_mk)
        controller_mk = tpl.substitute({'controller_class': self.plugin_name.replace("_", "")+"Controller", 'pname': self.plugin_name})
        controller_mk = controller_mk.replace("$&", "$")
        controller_folder_path = os.path.join(self.plugin_path, "controller")
        if os.path.exists(controller_folder_path):
            controller_file_path = os.path.join(controller_folder_path, ("%s_controller.php" % self.convert_camel_case(self.plugin_name.replace("_", ""))).lower())
            if not os.path.exists(controller_file_path):
                with open(controller_file_path, "w") as cf_file:
                    cf_file.write(controller_mk)
        views_folder_path =  os.path.join(self.plugin_path, "views")
        if os.path.exists(views_folder_path):
            index_view = os.path.join(views_folder_path, "index.tpl")
            with open(index_view, "w") as idx_file:
                index_content = '''
{assign var="paging_titles" value="$pname"}
{include file="paging.html"}

{literal}
    <script type='text/javascript'>
    //<![CDATA[
    $&(document).ready(function(){
       //your ready code here
    });
    //]]>
    </script>
{/literal}

<h1>$pname index action title</h1>
<p>
<font class="error">{$&error_msg}</font>
<p>
<form action="" method="POST" name="index_frm">
{$&form_redir}
Your custom code goes here
</form>
'''
                idx_tpl = TemplateIgnoreInvalid(index_content)
                index_content = idx_tpl.substitute({'pname': self.plugin_name})
                index_content = index_content.replace("$&", "$")
                idx_file.write(index_content)