[POS-commit] r52 - Stoq2/lib/domain

Henrique Romano henrique at async.com.br
Wed Mar 2 17:48:24 BRT 2005


Author: henrique
Date: 2005-03-02 17:48:23 -0300 (Wed, 02 Mar 2005)
New Revision: 52

Added:
   Stoq2/lib/domain/profile.py
Log:
Fix for bug 1827: Profile module implementation

Initial implementation of profile module.

r=evandro


Added: Stoq2/lib/domain/profile.py
===================================================================
--- Stoq2/lib/domain/profile.py	2005-03-02 18:59:54 UTC (rev 51)
+++ Stoq2/lib/domain/profile.py	2005-03-02 20:48:23 UTC (rev 52)
@@ -0,0 +1,86 @@
+# -*- Mode: Python; coding: iso-8859-1 -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+##
+## Copyright (C) 2004 Async Open Source <http://www.async.com.br>
+## All rights reserved
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+## USA.
+##
+"""
+lib/domain/profile.py:
+
+    Classes related to user's profile.
+
+"""
+
+from domain import Persistent, attr, Model
+from BTree.OOBTree import OOBTree
+
+class AppDescription(Persistent):
+    """ Class responsible for keeping informations of an application. This is
+    used as much as a key for the application dictionary of Profile class,
+    than in the profile editor of admin application. """
+
+    name = ""
+    description = ""
+
+class ProfileSettings(Persistent):
+    """ Class responsible for keeping permission data related to application's
+    "editors" and widgets. This class is used as a value associated to a 
+    AppDescription key by the OOBTree dictionary 'applications' of a Profile 
+    object; in other words, each Profile object will contain a dictionary that
+    will use AppDescription as key and this object (ProfileSettings) as your 
+    value. 
+
+    Atributes:
+        * access: determine if the profile associated to this object have 
+          access to key associated to this value (this object)
+
+        * node: a OOBTree dictionary, where each key (an AppDescription 
+          object) represents a editor of an application OR its widget (it is 
+          interesting to note that this object is used to determine access for
+          editors and their widgets) which this object is associated with we 
+          will have. When we have a key that represents a editor, its value 
+          will be ProfileSettings object, which goal is to be able to set 
+          permissions for all the widgets of this editor... If the key is a 
+          widget, its value will be boolean type, indicating if the profile 
+          associated is allowed to view (to use) this widget. 
+    """
+
+    access = None
+    node = OOBTree()
+
+class Profile(Model):
+    """ Class that represents a profile. 
+    
+    Atributes:
+        * name: the name of profile (a string, eg. "salesman")
+
+        * applications: we have here a dictionary, where the keys are
+          AppDescription objects and your correspondent values are
+          ProfileSettings objects. 
+    """
+
+    _ic_options = [attr('name', str)]
+
+    _required_attrs = ['name']
+
+    def __init__(self):
+        Model.__init__(self)
+        self.name = name
+        self.applications = OOBTree()
+



More information about the POS-commit mailing list