Package fliesclient :: Package flieslib :: Module jsonmodel
[hide private]
[frames] | no frames]

Source Code for Module fliesclient.flieslib.jsonmodel

 1  #vim:set et sts=4 sw=4:  
 2  #  
 3  # Flies Python Client 
 4  # 
 5  # Copyright (c) 2010 Jian Ni <jni@redhat.com> 
 6  # Copyright (c) 2010 Red Hat, Inc. 
 7  # 
 8  # This library is free software; you can redistribute it and/or 
 9  # modify it under the terms of the GNU Lesser General Public 
10  # License as published by the Free Software Foundation; either 
11  # version 2 of the License, or (at your option) any later version. 
12  # 
13  # This library is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU Lesser General Public License for more details. 
17  # 
18  # You should have received a copy of the GNU Lesser General Public 
19  # License along with this program; if not, write to the 
20  # Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
21  # Boston, MA  02111-1307  USA 
22   
23   
24  __all__ = ( 
25          "BaseModel", 
26     ) 
27   
28  import json 
29 30 -class BaseModel():
31 - def __init__(self, json = {}):
32 self.json = json
33
34 - def to_json(self):
35 return json.JSONEncoder().encode(self.json)
36 37 @property
38 - def id(self):
39 return self.json.get('id')
40 41 @id.setter
42 - def id(self, id):
43 self.json['id'] = id
44 45 @property
46 - def name(self):
47 return self.json.get('name')
48 49 @name.setter
50 - def name(self, name):
51 print "name"+name 52 self.json['name'] = name
53 54 @property
55 - def desc(self):
56 return self.json.get('description')
57 58 @desc.setter
59 - def desc(self, desc):
60 self.json['description'] = desc
61 62 @property
63 - def type(self):
64 return self.json.get('type')
65 66 @type.setter
67 - def type(self, type):
68 self.json['type'] = type
69