zoom.models module¶
zoom.models
common models
-
zoom.models.Attachment¶ alias of
zoom.models.SystemAttachment
-
class
zoom.models.Group¶ Bases:
zoom.utils.RecordZoom Users Group
>>> zoom.system.site = site = zoom.sites.Site() >>> groups = Groups(site.db) >>> group = groups.first(name='users')
>>> user = site.users.first(username='admin') >>> group.allows(user, 'edit') True
>>> group.key '2'
>>> group.url '/admin/groups/2'
>>> group.link '<a href="/admin/groups/2" name="link-to-users">users</a>'
>>> group.roles {4}
>>> zoom.utils.pp(group.apps) { 10, 12, 20, 28, 29 }
>>> groups.first(name='everyone').subgroups {2, 3}
>>> groups.first(name='users').user_ids [2] >>> {u.username for u in site.users.get(groups.first(name='users').user_ids)} {'user'}
-
add_user(user)¶
-
allows(user, action)¶
-
apps¶ Return set of apps that group can access
-
get_users()¶
-
key¶
-
link¶ user as link
-
roles¶
-
subgroups¶ Return set of subgroups that are part of this group
-
url¶ user view url
-
user_ids¶ Return list of user IDs of users that are in the group
-
users¶ Return list of users that are part of this group
-
-
class
zoom.models.Groups(db, entity=<class 'zoom.models.Group'>)¶ Bases:
zoom.records.RecordStore-
locate(locator)¶ locate a group whether it is referred to by reference, id or name
-
-
class
zoom.models.Member¶ Bases:
zoom.utils.Record
-
class
zoom.models.Members(db, entity=<class 'zoom.models.Member'>)¶ Bases:
zoom.records.RecordStore
-
class
zoom.models.Model¶ Bases:
zoom.utils.DefaultRecordModel Superclass
Provide basic model properties and functions.
Subclass this to create a Model that can be stored in a RecordStore, EntityStore or some other type of store.
Assumes every record has an id attribute. If not, you will need to provide one via an additional property defined in the subclass.
The key can end up being just the str of the id, however it is provided separately to make it easy to provide human friendly keys typically used in REST style URLs. If used this way the key should generated such that it is unique for each record.
>>> zoom.system.site = site = zoom.sites.Site() >>> zoom.system.request = zoom.utils.Bunch(route=[]) >>> class MyModel(Model): ... pass >>> thing = MyModel(name='Pat Smith')
>>> thing.name 'Pat Smith'
>>> thing.key 'pat-smith'
>>> url_for_item('pat-smith') '/pat-smith'
>>> thing.url '/pat-smith'
>>> thing.link '<a href="/pat-smith" name="link-to-pat-smith">Pat Smith</a>'
>>> thing.allows('user', 'edit') False
-
allows(user, action)¶
-
key¶ Return the key
-
link¶ Return a link
-
url¶ Return a valid URL
-
-
class
zoom.models.SystemAttachment¶ Bases:
zoom.utils.Record
-
zoom.models.get_users(db, group)¶ Get users of a Group
Gets the users that are members of a group from a given database.
>>> site = zoom.sites.Site() >>> users_group = Groups(site.db).first(name='users') >>> get_users(site.db, users_group) {2}
-
zoom.models.handler(request, handler, *rest)¶