Package ajango :: Package database :: Package columns :: Module default
[hide private]
[frames] | no frames]

Source Code for Module ajango.database.columns.default

 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  """ Modul domyslnej kolumny. """ 
20   
21  from ajango.database.columns import ColumnBase 
22   
23 -class Column(ColumnBase):
24 """ Klasa domyslnej kolumny. """
25 - def __init__(self, xmldoc, param=None):
26 self.presentation = [] 27 ColumnBase.__init__(self, xmldoc, param)
28 - def pre_init(self):
29 """ Czynnosci do wykonania przed inicjalizacja. """ 30 self.type = 'default' 31 self.add_permited(["PRESENTATION"])
32 - def read_from_dict(self, params):
33 """ Inicjalizacja ze zmiennej slownikowej. """ 34 ColumnBase.read_from_dict(self, params) 35 try: 36 self.presentation = self.object['presentation'] 37 except KeyError: 38 self.presentation = []
39 - def check(self, name, xmldoc_elem):
40 """ Oczytanie nodow wewnetrznych. """ 41 if name == 'PRESENTATION': 42 presentation_type = xmldoc_elem.getAttribute('type') 43 self.presentation.append(presentation_type)
44 - def execute(self, view, view_name="view"):
45 """ Wykonanie czynnosci kolumny. """ 46 if len(self.presentation) > 0: 47 view.add_import("presentation_factory", 48 "ajango.site.presentations") 49 view.add_line("p = []") 50 for elem in self.presentation: 51 view.add_line("p.append(presentation_factory(%r))" % elem) 52 view.add_line("%s.add_column({'type' : 'default', " 53 "'label' : %r, " 54 "'tag' : %r, " 55 "'presentation' : p })" % 56 (view_name, self.label, self.tag)) 57 else: 58 view.add_line("%s.add_column({'type' : 'default', " 59 "'label' : %r, " 60 "'tag' : %r })" % 61 (view_name, self.label, self.tag))
62 - def get_data(self, value=None):
63 """ Pobranie danych dla szablonu. """ 64 self.prepare_data() 65 result = value['result'] 66 data = dict(self.data) 67 value = result.get_element(self.data['tag']) 68 for pres in self.presentation: 69 value = pres.get(value) 70 data['value'] = value 71 return data
72