def onNewItem(self):
        keywords = EVDBDialog.GetSearchDictFromDialog()

        result = None

        while keywords:
            try:
                result = evdb.GetCollectionFromSearch(self.itsView, keywords)
            except evdb.LicenseError:
                if promptLicense():
                    continue
            except Exception, e:
                logger.exception(
                    "An error occurred while fetching events from EVDB")
                wx.MessageBox(_(
                    u"An error occurred while fetching events from EVDB:\n%(error)s\n\nSee chandler.log for details."
                ) % {'error': e},
                              _(u"EVDB Search"),
                              parent=wx.GetApp().mainFrame)
            else:
                if len(list(result)) == 0:
                    result.delete()
                    result = None
                    wx.MessageBox(_(u"No matching events were found."),
                                  _(u"EVDB Search"),
                                  parent=wx.GetApp().mainFrame)
            return result
    def onNewItem(self):
        """
        Called to create a new collection that gets added to the sidebar.
        """
        photoCollection = None
        if self.collectionType == 'Owner':
            userName = promptUser(messages.USERNAME,
                                  _(u"Enter a Flickr user name"))
            if userName is not None:
                photoCollection = PhotoCollection(itsView=self.itsView)
                photoCollection.userName = userName
                photoCollection.displayName = userName
        else:
            assert (self.collectionType == 'Tag')
            tagString = promptUser(_(u"Tag"), _(u"Enter a Flickr Tag"))
            if tagString is not None:
                photoCollection = PhotoCollection(itsView=self.itsView)
                photoCollection.tag = Tag.getTag(self.itsView, tagString)
                photoCollection.displayName = photoCollection.tag.displayName

        if photoCollection is not None:
            # Setting preferredKind to None will cause it to be displayed in
            # the All View
            UserCollection(photoCollection).preferredClass = MissingClass
            while True:
                try:
                    photoCollection.fillCollectionFromFlickr(self.itsView)
                    photoCollection.fillInBackground = True
                    break
                except flickr.FlickrError, e:
                    if "api key" in e.args[0].lower():
                        if promptLicense():
                            continue
                    wx.MessageBox(unicode(e),
                                  _(u"Flickr Error"),
                                  parent=wx.GetApp().mainFrame)
                    photoCollection.delete()
                    photoCollection = None
                    break
Example #3
0
    def onNewItem(self):
        """
        Called to create a new collection that gets added to the sidebar.
        """
        photoCollection = None
        if self.collectionType == 'Owner':
            userName = promptUser(messages.USERNAME,
                                  _(u"Enter a Flickr user name"))
            if userName is not None:
                photoCollection = PhotoCollection(itsView=self.itsView)
                photoCollection.userName = userName
                photoCollection.displayName = userName
        else:
            assert (self.collectionType == 'Tag')
            tagString = promptUser(_(u"Tag"),
                                   _(u"Enter a Flickr Tag"))
            if tagString is not None:
                photoCollection = PhotoCollection(itsView=self.itsView)
                photoCollection.tag = Tag.getTag(self.itsView, tagString)
                photoCollection.displayName = photoCollection.tag.displayName

        if photoCollection is not None:
            # Setting preferredKind to None will cause it to be displayed in
            # the All View 
            UserCollection(photoCollection).preferredClass = MissingClass
            while True:
                try:
                    photoCollection.fillCollectionFromFlickr(self.itsView)
                    photoCollection.fillInBackground = True
                    break
                except flickr.FlickrError, e:
                    if "api key" in e.args[0].lower():
                        if promptLicense():
                            continue
                    wx.MessageBox(unicode(e), _(u"Flickr Error"),
                                  parent=wx.GetApp().mainFrame)
                    photoCollection.delete()
                    photoCollection = None
                    break
Example #4
0
 def onNewItem(self):
     keywords = EVDBDialog.GetSearchDictFromDialog()
     
     result = None
     
     while keywords:
         try:
             result = evdb.GetCollectionFromSearch(self.itsView, keywords)
         except evdb.LicenseError:
             if promptLicense():
                 continue
         except Exception, e:
             logger.exception("An error occurred while fetching events from EVDB")
             wx.MessageBox (_(u"An error occurred while fetching events from EVDB:\n%(error)s\n\nSee chandler.log for details.") % {'error': e},
                            _(u"EVDB Search"),
                            parent=wx.GetApp().mainFrame)
         else:
             if len(list(result)) == 0:
                 result.delete()
                 result = None
                 wx.MessageBox(_(u"No matching events were found."),
                               _(u"EVDB Search"),
                               parent=wx.GetApp().mainFrame)
         return result