Mercurial > p > roundup > code
comparison roundup/templates/extended/dbinit.py @ 905:502a5ae11cc5
Very close now. The cgi and mailgw now use the new security API.
The two templates have been migrated to that setup. Lots of unit
tests. Still some issue in the web form for editing Roles assigned to
users.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 26 Jul 2002 08:27:00 +0000 |
| parents | 2dd862af72ee |
| children | 23c9d4f86380 |
comparison
equal
deleted
inserted
replaced
| 904:02763530b9e8 | 905:502a5ae11cc5 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: dbinit.py,v 1.23 2002-07-14 02:05:54 richard Exp $ | 18 # $Id: dbinit.py,v 1.24 2002-07-26 08:27:00 richard Exp $ |
| 19 | 19 |
| 20 import os | 20 import os |
| 21 | 21 |
| 22 import instance_config | 22 import instance_config |
| 23 from select_db import Database, Class, FileClass, IssueClass | 23 from select_db import Database, Class, FileClass, IssueClass |
| 24 | 24 |
| 25 def open(name=None): | 25 def open(name=None): |
| 26 ''' as from the roundupdb method openDB | 26 ''' as from the roundupdb method openDB |
| 27 | |
| 28 ''' | 27 ''' |
| 29 from roundup.hyperdb import String, Password, Date, Link, Multilink | 28 from roundup.hyperdb import String, Password, Date, Link, Multilink |
| 30 | 29 |
| 31 # open the database | 30 # open the database |
| 32 db = Database(instance_config, name) | 31 db = Database(instance_config, name) |
| 54 | 53 |
| 55 user = Class(db, "user", | 54 user = Class(db, "user", |
| 56 username=String(), password=Password(), | 55 username=String(), password=Password(), |
| 57 address=String(), realname=String(), | 56 address=String(), realname=String(), |
| 58 phone=String(), organisation=String(), | 57 phone=String(), organisation=String(), |
| 59 alternate_addresses=String()) | 58 alternate_addresses=String(), |
| 59 queries=Multilink('query'), roles=String()) | |
| 60 user.setkey("username") | 60 user.setkey("username") |
| 61 | 61 |
| 62 # FileClass automatically gets these properties: | 62 # FileClass automatically gets these properties: |
| 63 # content = String() [saved to disk in <instance home>/db/files/] | 63 # content = String() [saved to disk in <instance home>/db/files/] |
| 64 # (it also gets the Class properties creation, activity and creator) | 64 # (it also gets the Class properties creation, activity and creator) |
| 109 issue = IssueClass(db, "issue", | 109 issue = IssueClass(db, "issue", |
| 110 assignedto=Link("user"), priority=Link("priority"), | 110 assignedto=Link("user"), priority=Link("priority"), |
| 111 status=Link("status"), product=Link("product"), | 111 status=Link("status"), product=Link("product"), |
| 112 platform=Multilink("platform"), version=String(), | 112 platform=Multilink("platform"), version=String(), |
| 113 targetversion=String(), supportcall=Multilink("support")) | 113 targetversion=String(), supportcall=Multilink("support")) |
| 114 | |
| 115 # | |
| 116 # SECURITY SETTINGS | |
| 117 # | |
| 118 # new permissions for this schema | |
| 119 for cl in 'issue', 'support', 'file', 'msg': | |
| 120 db.security.addPermission(name="Edit", klass=cl, | |
| 121 description="User is allowed to edit "+cl) | |
| 122 db.security.addPermission(name="View", klass=cl, | |
| 123 description="User is allowed to access "+cl) | |
| 124 | |
| 125 # Assign the appropriate permissions to the anonymous user's Anonymous | |
| 126 # Role. Choices here are: | |
| 127 # - Allow anonymous users to register through the web | |
| 128 p = db.security.getPermission('Web Registration') | |
| 129 db.security.addPermissionToRole('Anonymous', p) | |
| 130 # - Allow anonymous (new) users to register through the email gateway | |
| 131 p = db.security.getPermission('Email Registration') | |
| 132 db.security.addPermissionToRole('Anonymous', p) | |
| 133 # - Allow anonymous users access to the "issue" class of data | |
| 134 # Note: this also grants access to related information like files, | |
| 135 # messages, statuses etc that are linked to issues | |
| 136 #p = db.security.getPermission('View', 'issue') | |
| 137 #db.security.addPermissionToRole('Anonymous', p) | |
| 138 # - Allow anonymous users access to edit the "issue" class of data | |
| 139 # Note: this also grants access to create related information like | |
| 140 # files and messages etc that are linked to issues | |
| 141 #p = db.security.getPermission('Edit', 'issue') | |
| 142 #db.security.addPermissionToRole('Anonymous', p) | |
| 143 | |
| 144 # Assign the access and edit permissions for issue, file and message | |
| 145 # to regular users now | |
| 146 for cl in 'issue', 'support', 'file', 'msg': | |
| 147 p = db.security.getPermission('View', cl) | |
| 148 db.security.addPermissionToRole('User', p) | |
| 149 p = db.security.getPermission('Edit', cl) | |
| 150 db.security.addPermissionToRole('User', p) | |
| 114 | 151 |
| 115 import detectors | 152 import detectors |
| 116 detectors.init(db) | 153 detectors.init(db) |
| 117 | 154 |
| 118 # schema is set up - run any post-initialisation | 155 # schema is set up - run any post-initialisation |
| 171 product.create(name='Bizar Shop Manual', order="3") | 208 product.create(name='Bizar Shop Manual', order="3") |
| 172 product.create(name='Bizar Shop Developer Manual', order="4") | 209 product.create(name='Bizar Shop Developer Manual', order="4") |
| 173 | 210 |
| 174 user = db.getclass('user') | 211 user = db.getclass('user') |
| 175 user.create(username="admin", password=adminpw, | 212 user.create(username="admin", password=adminpw, |
| 176 address=instance_config.ADMIN_EMAIL) | 213 address=instance_config.ADMIN_EMAIL, roles="Admin") |
| 214 user.create(username="anonymous", roles='Anonymous') | |
| 177 | 215 |
| 178 db.commit() | 216 db.commit() |
| 179 | 217 |
| 180 # | 218 # |
| 181 # $Log: not supported by cvs2svn $ | 219 # $Log: not supported by cvs2svn $ |
| 220 # Revision 1.23 2002/07/14 02:05:54 richard | |
| 221 # . all storage-specific code (ie. backend) is now implemented by the backends | |
| 222 # | |
| 182 # Revision 1.22 2002/07/09 03:02:53 richard | 223 # Revision 1.22 2002/07/09 03:02:53 richard |
| 183 # More indexer work: | 224 # More indexer work: |
| 184 # - all String properties may now be indexed too. Currently there's a bit of | 225 # - all String properties may now be indexed too. Currently there's a bit of |
| 185 # "issue" specific code in the actual searching which needs to be | 226 # "issue" specific code in the actual searching which needs to be |
| 186 # addressed. In a nutshell: | 227 # addressed. In a nutshell: |
