def user_set_settings(user, **kwargs): """Set user profile: name Full name bio about-me text anon_blog 'yes' if anon users can read personal news email_notify 'yes' if user should receive e-mail notices of incoming messages """ user.set_contact_name(_unicode_fix(kwargs['name'])) user.bio = _unicode_fix(kwargs['bio']) user.location = _unicode_fix(kwargs['location']) user.latitude = kwargs['latitude'] user.longitude = kwargs['longitude'] user.deliciousID = kwargs['deliciousID'] user.flickrID = kwargs['flickrID'] user.skypeID = kwargs['skypeID'] user.blogURL = kwargs['blogURL'] user.get_user_data().set_anon_can_read_blog(kwargs['anon_blog'] == 'yes') user.set_email_notify(kwargs['email_notify'] == 'yes') user.set_copy_self(kwargs['copy_self'] == 'yes') transaction_commit(user, 'UserPrefs') # moved from user.ptl/UserPrefsForm.commit() qon.search.searchengine.notify_edited_user(user) get_observe_database().notify_changed(user) # FIXME this should be in user.py somewhere
def add_dependency(self, target): """Register self as being dependent on target.""" # add to my targets list self.__targets.append(target) # tell observe db i'm dependent on target get_observe_database().observe(target, self)
def remove_dependency(self, target): """I am no longer dependent on target.""" # remove from my targets list while target in self.__targets: self.__targets.remove(target) # stop observing get_observe_database().stop_observing(target, self)
def watchable_changed(self, now=None): """Call this when object changes in a noticeable way. If now is not provided, calls datetime.utcnow. """ if not self.watchable(): return # we rely on _p_oid machinerey if not isinstance(self, Persistent): raise NotImplementedError, "only Persistent objects are watchable." # notify observe database that this watchable has changed get_observe_database().notify_changed(self) self.__last_change = datetime.utcnow() self._p_changed = 1
def remove_all_dependencies(self): """Remove and unregister all dependencies.""" db = get_observe_database() for target in self.__targets: db.stop_observing(target, self) # flush targets list del self.__targets[:]
def out_of_date_wrt(self): """Return list of objects I am out of date with respect to.""" ood = [] db = get_observe_database() for target in self.__targets: if not db.up_to_date(target, self): ood.append(target) return ood
def up_to_date(self): """Return True if none of my targets have changed since I added them as a dependency.""" db = get_observe_database() for target in self.__targets: if not db.up_to_date(target, self): return False return True