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

Source Code for Package ajango.database.columns

 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 zarzadzania kolumnami. """ 
20   
21  from django.core.management.base import CommandError 
22  from ajango.core.factory         import FactoryBase 
23  from ajango.core.generable       import Generable 
24  from ajango.core.hybrid          import Hybrid, get_str_object_factory 
25  import abc 
26 27 -class ColumnFactoryObject(FactoryBase):
28 """ Klasa obiektu zarzadzajacego kolumnami. """
29 - def init(self):
30 """ Metoda inicjalizujaca. """ 31 self.set_items('Column', { 32 'default' : 'ajango.database.columns.default', 33 'button' : 'ajango.database.columns.button' 34 }) 35 get_str_object_factory(self)
36
37 -def column_factory(param):
38 """ Fabryka kolumn. """ 39 return ColumnFactoryObject(param).get_from_params()
40
41 -class ColumnBase(Hybrid, Generable):
42 """ Klasa bazowa obiektu obslugujacego kolumny. """ 43 __metaclass__ = abc.ABCMeta
44 - def __init__(self, xmldoc, param=None):
45 self.type = "unKnown" 46 self.theme = 'default' 47 self.has_prepare = False 48 self.data = {} 49 self.xml_name = "COLUMN" 50 self.label = "" 51 self.tag = "" 52 self.pre_init() 53 Hybrid.__init__(self, xmldoc) 54 self.post_init()
55 - def read_from_xml(self, xmldoc):
56 """ Inicjalizacja z danych XML. """ 57 self.label = self.getAttribute('label') 58 self.tag = self.getAttribute('tag')
59 - def read_from_dict(self, params):
60 """ Inicjalizacja ze zmiennej slownikowej. """ 61 try: 62 self.label = params['label'] 63 self.tag = params['tag'] 64 except KeyError: 65 raise CommandError("Input element is invalid")
66 - def pre_init(self):
67 """ Czynnosci do wykonania przed inicjalizacja. """ 68 pass
69 - def post_init(self):
70 """ Czynnosci do wykonania po inicjalizacji. """ 71 pass
72 - def check(self, name, xml_doc_elem):
73 """ Oczytanie nodow wewnetrznych. """ 74 pass
75 - def prepare_data(self):
76 """ Przygotowanie danych. """ 77 if self.has_prepare: 78 return 79 self.has_prepare = True 80 self.data['tag'] = self.tag 81 self.data['label'] = self.label 82 self.data['url'] = '%s/ajango_columns/%s.html' % (self.theme, self.type)
83 @abc.abstractmethod
84 - def get_data(self, value=None):
85 """ Pobranie danych dla szablonu. """ 86 raise CommandError("Please implement this method")
87 - def get_label(self):
88 """ Pobranie opisu kolumny. """ 89 self.prepare_data() 90 return self.label
91