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

Source Code for Module ajango.generator.views.list

 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 'list'. 
21   
22  Obiekt generuje kod obsugujacy strone wyswietlajaca liste rekordow. Dane sa 
23  wybierane na postawie zapytania podanego w znaczniku B{QUERY}. 
24   
25  Dostepne znaczniki 
26  ================== 
27   
28      1. B{QUERY} - Zapytanie o dane. L{wiecej <ajango.database.query>}. 
29      2. B{COLUMN} - Kolumna z danymi L{wiecej <ajango.database.columns>}. 
30   
31  Generowany obiekt 
32  ================= 
33   
34  L{ajango.site.sites.list} 
35  """ 
36   
37  from django.core.management.base import CommandError 
38  from ajango.generator.views      import ViewBase 
39  from ajango.database.columns     import column_factory 
40  from ajango.database.query       import Query 
41   
42 -class View(ViewBase):
43 """ Klasa widoku wyswietlajacego liste danych. """
44 - def __init__(self, xmldoc, importRenderer, app):
45 self.column = [] 46 self.query = None 47 ViewBase.__init__(self, xmldoc, importRenderer, app)
48 - def init(self):
49 """ Metoda inicjalizujaca. """ 50 self.type = "list" 51 self.add_permited(["QUERY", "COLUMN"])
52 - def post_init(self):
53 """ Czynnosci do wykonania po inicjalizacji. """ 54 if self.query == None: 55 raise CommandError("Query object define") 56 if len(self.column) == 0: 57 raise CommandError("Don't define any column")
58 - def check(self, name, xmldoc_elem):
59 """ Oczytanie nodow wewnetrznych. """ 60 if ViewBase.check(self, name, xmldoc_elem): 61 return True 62 if name.upper() == "QUERY": 63 self.query = Query(xmldoc_elem) 64 return True 65 if name.upper() == "COLUMN": 66 self.column.append(column_factory(xmldoc_elem)) 67 return True 68 return False
69 - def execute(self, view, view_name="view"):
70 """ Wykonanie zadan obiektu. """ 71 self.query.execute(self, view_name) 72 for elem in self.column: 73 elem.execute(self, view_name)
74