def __new__(cls, *args): self = object.__new__(cls) factory = lambda x: x if not args: return self # just an empty instance itemOrAnnotation = args[0] if isinstance(itemOrAnnotation, schema.Annotation): factory = type(itemOrAnnotation) item = itemOrAnnotation.itsItem else: item = itemOrAnnotation if reminders.isDead(item): return None if item.isProxy: self.proxy = type(item)(item.proxiedItem) else: self.proxy = RecurrenceProxy(item) self.proxy.changing = cls return factory(self.proxy)
def __new__(cls, *args): self = object.__new__(cls) factory = lambda x:x if not args: return self # just an empty instance itemOrAnnotation = args[0] if isinstance(itemOrAnnotation, schema.Annotation): factory = type(itemOrAnnotation) item = itemOrAnnotation.itsItem else: item = itemOrAnnotation if reminders.isDead(item): return None if item.isProxy: self.proxy = type(item)(item.proxiedItem) else: self.proxy = RecurrenceProxy(item) self.proxy.changing = cls return factory(self.proxy)
def __new__(proxyClass, itemOrAnnotation): if isinstance(itemOrAnnotation, schema.Annotation): annotationClass = type(itemOrAnnotation) return annotationClass(proxyClass(itemOrAnnotation.itsItem)) item = getattr(itemOrAnnotation, 'proxiedItem', itemOrAnnotation) if reminders.isDead(itemOrAnnotation): return None return object.__new__(proxyClass)
def markProxyEdited(self, proxy, attrs): if self.editedItems: for item in self.editedItems: if not reminders.isDead(item): with EventStamp(item).noRecurrenceChanges(): for attr in self.EDIT_ATTRIBUTES: if item.hasLocalAttributeValue(attr): delattr(item, attr) del self.editedItems super(CHANGE_ALL, self).markProxyEdited(proxy, attrs)
def markEdited(self, item, attrs): attrs.difference_update(_IGNORE_EDIT_ATTRIBUTES) if not attrs or reminders.isDead(getattr(item, 'proxiedItem', item)): return me = item.getCurrentMeEmailAddress() who = None # We will mark this message as "edited by" this user. if stamping.has_stamp(item, mail.MailStamp): # For Mail items, we want to update the From: address of the master # to match something in the user's list of addresses (Bug 8534). # We actually want to bypass all proxying here, and apply the # CC/From header changes to the master item. mailItem = getattr(item, 'proxiedItem', item) message = mail.MailStamp(getattr(mailItem, 'inheritFrom', mailItem)) if stamping.has_stamp(message, mail.MailStamp): meAddresses = mail.getCurrentMeEmailAddresses(item.itsView) sender = message.getSender() if sender in meAddresses: # Already addressed by this user; don't need to do # anything more here. who = sender else: # Try to find a matching recipient; any field will do # (so far as arguments to getRecipients() go, we've already # preferentially excluded the sender, but should still check # originators & bcc). Also, if we're just now marking the item # as edited for the first time, make sure the (old) sender's in # the CC list. addSenderToCC = (sender is not None) and \ (items.Modification.edited not in item.modifiedFlags) for recipient in message.getRecipients(): if who is None and recipient in meAddresses: who = recipient if addSenderToCC and sender is recipient: addSenderToCC = False if who is None: # No match in for loop; use the current "me" address who = me if addSenderToCC: message.ccAddress.append(sender) # Update the from address message.fromAddress = who if who is None: who = item.getMyModifiedByAddress() item.changeEditState(who=who)