Package ajango :: Package generator :: Package views :: Module input
[hide private]
[frames] | no frames]

Source Code for Module ajango.generator.views.input

 1  ########################################################################### 
 2  #                                                                         # 
 3  #  Copyright (C) 2016  Rafal Kobel <rafyco1@gmail.com>                    # 
 4  #                                                                         # 
 5  #  This program is free software: you can redistribute it and/or modify   # 
 6  #  it under the terms of the GNU General Public License as published by   # 
 7  #  the Free Software Foundation, either version 3 of the License, or      # 
 8  #  (at your option) any later version.                                    # 
 9  #                                                                         # 
10  #  This program is distributed in the hope that it will be useful,        # 
11  #  but WITHOUT ANY WARRANTY; without even the implied warranty of         # 
12  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the           # 
13  #  GNU General Public License for more details.                           # 
14  #                                                                         # 
15  #  You should have received a copy of the GNU General Public License      # 
16  #  along with this program.  If not, see <http://www.gnu.org/licenses/>.  # 
17  #                                                                         # 
18  ########################################################################### 
19  """ 
20  Obiekt generujacy strone typu 'input'. 
21   
22  Obiekt generuje kod obsugujacy strone agregujaca widoki. 
23   
24  Dostepne znaczniki 
25  ================== 
26   
27      1. B{TABLE} - Tabela do ktorej nalezy wstawic dane. 
28          - I{name} - Nazwa tabeli. 
29      2. B{INPUT} - Element przyjmujacy dane L{wiecej <ajango.database.inputs>}. 
30   
31  Generowany obiekt 
32  ================= 
33   
34  L{ajango.site.sites.input} 
35  """ 
36   
37  from django.core.management.base import CommandError 
38  from ajango.generator.views import ViewBase 
39  from ajango.database.inputs import input_factory 
40   
41 -class View(ViewBase):
42 """ Klasa generujaca widok wprowadzania danych. """
43 - def __init__(self, xmldoc, importRenderer, app):
44 self.table = "" 45 self.inputs = [] 46 ViewBase.__init__(self, xmldoc, importRenderer, app)
47 - def init(self):
48 """ Metoda inicjalizujaca. """ 49 self.type = "input" 50 self.add_permited(["TABLE", "INPUT"])
51 - def post_init(self):
52 """ Czynnosci do wykonania po inicjalizacji. """ 53 if self.table == "": 54 raise CommandError("Table name isn't define") 55 if len(self.inputs) == 0: 56 raise CommandError("Don't define any input object")
57 - def check(self, name, xmldoc_elem):
58 """ Oczytanie nodow wewnetrznych. """ 59 if super(View, self).check(name, xmldoc_elem): 60 return True 61 if name.upper() == "TABLE": 62 self.table = xmldoc_elem.getAttribute("name") 63 return True 64 if name.upper() == "INPUT": 65 self.inputs.append(input_factory(xmldoc_elem)) 66 return True 67 return False
68 - def execute(self, view, view_name='view'):
69 """ Wykonanie zadan obiektu. """ 70 self.add_import("models", ".") 71 self.add_line("%s.set_models(models)" % view_name) 72 self.add_line("%s.set_table_name(%r)" % (view_name, self.table)) 73 for elem in self.inputs: 74 elem.execute(self, view_name)
75