コード例 #1
0
ファイル: ia.py プロジェクト: BackupTheBerlios/cctools-svn
    def __init__(self, parent, storage):
        # check if we have persisted values for username/passwd
        username = p6.metadata.persistance.load("ia", "username", "")
        password = p6.metadata.persistance.load("ia", "password", "")
        persist  = p6.metadata.persistance.load("ia", "persist", False)

        # create the simple page
        fields = [
            p6.metadata.base.metadatafield(p6.metadata.types.ITextField)(
            'username', _('Username'), default=username),
            p6.metadata.base.metadatafield(p6.metadata.types.IPasswordField)(
            'password', _('Password'), default=password),
            p6.metadata.base.metadatafield(p6.metadata.types.IBooleanField)(
            'persist', _('Save your username and password?'), default=persist)
            ]

        description=_("Enter your Internet Archive username and password.  "
                      "If you do not have a username and password, visit "
                      "http://archive.org to create an account.")

        p6.ui.pages.fieldrender.SimpleFieldPage.__init__(self,
                                                         parent,
                                                         'ARCHIVE_LOGIN',
                                                   _('Internet Archive login'),
                                                         fields,
                                                         self.callback,
                                                         description)
        self.storage = storage
コード例 #2
0
        def createPages(self):
            
            # XXX -- hack
            # 
            # We import here because doing so at instantiation causes problems
            # -- in particular, the App needs to be created before other
            # UI objects, and the import has side effects (querying the
            # background color)
            
            import p6.ui.pages.fieldrender
            
            # create the simple page
            fields = [
                p6.metadata.base.metadatafield(p6.metadata.types.ITextField)(
                'vurl', _('Verification URL')),
                ]

            self.__pages = []

            self.__pages.append(
                lambda x: p6.ui.pages.fieldrender.SimpleFieldPage(
                x, 'SELFHOST_UI_META', _('Self Hosted Files'), fields,
                self.callback,
                description=_("Please enter the URL where you will host your "
                              "verification metadata. In most cases, this "
                              "will be the page you link to your MP3 file "
                              "from.")
                ))

            self.__pages.append(
                lambda x: ui.selfhost.FinalPage(x, self.storage)
                )
コード例 #3
0
ファイル: ia.py プロジェクト: BackupTheBerlios/cctools-svn
    def onChanging(self, event):
        """Validate the proposed identifier."""

        if not(event.direction):
            # user clicked Prev instead of Next
            return
        
        archive_id = XRCCTRL(self, "TXT_IDENTIFIER").GetValue()

        if not(pyarchive.identifier.conforms(archive_id)):
            p6.api.showError(
                _("That identifier does not conform to the "
                "Internet Archive's naming standards.") )
            event.Veto()

        try:
            if not(pyarchive.identifier.available(archive_id)):
                p6.api.showError(
                    _("That identifier is not available.") )
                event.Veto()
        except pyarchive.exceptions.MissingParameterException, e:
            
            p6.api.showError(
                _("That identifier does not conform to the "
                "Internet Archive's naming standards.") )
            event.Veto()
コード例 #4
0
    def addFields(self, metaGroup, sizer):
        """Create the user input widgets for this group."""

        for field in metaGroup.getFields():

            label = wx.StaticText(self, label=_(field.label))
            sizer.Add(label)

            widget = p6.ui.interfaces.IEntryWidget(field)(self)
            field._widget = weakref.ref(widget)
            
            sizer.Add(widget, flag=wx.EXPAND)

            # check for a tooltip
            if field.tip:
                widget.SetToolTip(wx.ToolTip(_(field.tip)))

            # check for a description
            if field.description:
                sizer.Add((5,5))
                desc_label = wx.StaticText(self, label=_(field.description))
                sizer.Add(desc_label, flag=wx.EXPAND)

            # check if the field is persistant and try to load it
            if field.persist:

                persistUtility = zope.component.getUtility(
                    p6.metadata.persistance.IMetadataPersistance)
                
                value = persistUtility.query(self.metagroup.id,
                                             field.id)

                # see if we have a value for this field
                if value is not None:
                    widget.SetValue(value)
コード例 #5
0
ファイル: cch.py プロジェクト: BackupTheBerlios/cctools-svn
    def __init__(self, parent, storage):
        # check if we have persisted values for username/passwd
        username = p6.metadata.persistance.load("cch", "username", "")
        password = p6.metadata.persistance.load("cch", "password", "")
        persist  = p6.metadata.persistance.load("cch", "persist", False)

        # create the simple page
        fields = [
            p6.metadata.base.metadatafield(p6.metadata.types.ITextField)(
            'username', 'Username', default=username),
            p6.metadata.base.metadatafield(p6.metadata.types.IPasswordField)(
            'password', 'Password', default=password),
            p6.metadata.base.metadatafield(p6.metadata.types.IBooleanField)(
            'persist', 'Save your username and password?', default=persist)
            ]

        description=_("Enter your CCHost Installation username and password.")

        p6.ui.pages.fieldrender.SimpleFieldPage.__init__(self,
                                                         parent,
                                                         'CCHost_LOGIN',
                                                   _('CCHost Installation login'),
                                                         fields,
                                                         self.callback,
                                                         description)
        self.storage = storage
コード例 #6
0
    def addFields(self, field_list, sizer):
        """Create the user input widgets for this group."""

        for field in field_list:

            label = wx.StaticText(self, label=_(field.label))
            sizer.Add(label)

            widget = p6.ui.interfaces.IEntryWidget(field)(self)
            widget.SetValue(field.default)
            
            field._widget = weakref.ref(widget)
            
            sizer.Add(widget, flag=wx.EXPAND)

            # check for a tooltip
            if field.tip:
                widget.SetToolTip(wx.ToolTip(_(field.tip)))

            # check for a description
            if field.description:
                sizer.Add((5,5))
                desc_label = wx.StaticText(self, label=_(field.description))
                sizer.Add(desc_label, flag=wx.EXPAND)

	self.Fit()
コード例 #7
0
    def addFields(self, metaGroup, sizer):
        """Create the user input widgets for this group."""

        for field in metaGroup.getFields():

            label = wx.StaticText(self, label=_(field.label))
            sizer.Add(label)

            widget = p6.ui.interfaces.IEntryWidget(field)(self)
            field._widget = weakref.ref(widget)
            
            sizer.Add(widget, flag=wx.EXPAND)

            # check for a tooltip
            if field.tip:
                widget.SetToolTip(wx.ToolTip(_(field.tip)))

            # check for a description
            if field.description:
                sizer.Add((5,5))
                desc_label = wx.StaticText(self, label=_(field.description))
                sizer.Add(desc_label, flag=wx.EXPAND)

            # check if the field is persistant and try to load it
            if field.persist:
                print '... this field wants to persist...'
                event = p6.metadata.events.LoadMetadataEvent(
                    self.metagroup.appliesTo,
                    self.metagroup, field,
                    )

                zope.component.handle(event)
コード例 #8
0
ファイル: cch.py プロジェクト: BackupTheBerlios/cctools-svn
	def onChanging(self, event):
		if event.direction:
			if not(self.isSubmit()):
				# if it's not the submission form
			        # show an alert
			        wx.MessageDialog(None, _("You need to fill the submission form first!"), _("Error"), wx.OK).ShowModal()
				# veto the event -- don't allow the page to change w/o correction
				event.Veto()
コード例 #9
0
    def getLicenseClasses(self):
        """Calls the SOAP API via proxy to get a list of all available
        license class identifiers."""

        try:
            self.__l_classes = self.__cc_server.license_classes()
        except urllib2.URLError, e:
            wx.MessageBox("Unable to connect to the Internet to retrieve license information.  Check your connection and try again.",
                         caption=_("appname") + ": " + _("Error"),
                         style=wx.OK|wx.ICON_ERROR, parent=self.GetParent())
            self.GetParent().Close()
            return
コード例 #10
0
   def __updateNavBtns(self, event=None):

      if self.pages.is_last():
         XRCCTRL(self, "CMD_NEXT").SetLabel(_('Quit'))
      else:
         XRCCTRL(self, "CMD_NEXT").SetLabel(_('Next'))

      if self.pages.is_first():
         XRCCTRL(self, "CMD_PREV").Disable()
      else:
         XRCCTRL(self, "CMD_PREV").Enable()

      XRCCTRL(self, "CMD_NEXT").Enable()
コード例 #11
0
 def onChanging(self, event):
     try:
         if event.direction:
             return self.__validator(self.__assemble())
         else:
             return True
     except p6.extension.exceptions.ExtensionSettingsException, e:
         # an error occured while validating the extension settings
         # show an alert
         wx.MessageDialog(None, _(str(e)), _("Error"), wx.OK).ShowModal()
         
         # veto the event -- don't allow the page to change w/o correction
         event.Veto()
コード例 #12
0
ファイル: wxpy.py プロジェクト: BackupTheBerlios/cctools-svn
    def registerStorage(self, name, factory, description = ''):
        """Add a storage provider and associate the name and description."""

        # instantiate the provider
        provider = factory()

        # inject the name and description
        # XXX we should use a registry here; we inject for compatibility with
        # XXX existing code
        provider.name = _(name)
        provider.description = _(description)

        # add the provider to our list of storage providers
        self.storage.append(provider)
コード例 #13
0
 def validate(self, event):
     # make sure the user has selected at least one file...
     if event.direction:
         # only check if moving forward
         if self.__fileList.GetItemCount() > 0:
             return True
         else:
             # haven't selected anything; show an error message
             wx.MessageDialog(
                 self, _("You must select at least one file."), _("appname") + ": " + _("Error"), wx.OK
             ).ShowModal()
             return False
     else:
         # always allow moving back
         return True
コード例 #14
0
    def OnDropFiles(self, x, y, filenames):
        """Bridge dropped files to P6 events."""

        for filename in filenames:
            # check if this is a directory
            if os.path.isdir(filename):
                # we don't support adding directories
                wx.MessageDialog(
                    None,
                    _("Please drag and drop individual files on this window."),
                    _("appname") + ": " + _("Error"),
                    wx.OK,
                ).ShowModal()
                continue

            zope.component.handle(p6.storage.events.ItemSelected(p6.storage.items.FileItem(filename)))
コード例 #15
0
    def __init__(self, parent, headline=_('Select Your Files')):
        """
        @param parent: Parent window
        @type parent: L{wx.Window}

        @param headline: Title to display above the wizard page
        @type headline: String
        """
        
        ccwx.xrcwiz.XrcWizPage.__init__(self, parent,
                                        os.path.join(p6.api.getResourceDir(),
                                                     "p6.xrc"),
                                        "FILE_SELECTOR", headline)

        # connect event handlers for browse button, delete button, delete key
        self.Bind(wx.EVT_BUTTON, self.onBrowse, XRCCTRL(self, "CMD_BROWSE"))
        self.Bind(wx.EVT_BUTTON, self.onDelete, XRCCTRL(self, "CMD_DELETE"))
        self.Bind(wx.EVT_KEY_UP, self.onKeyUp,  self)
        
        # listen for item addition events
        zope.component.provideHandler(
            zope.component.adapter(p6.storage.events.IItemSelected)(
                p6.api.deinstify(self.selectItem))
            )

        # listen for item removal events
        zope.component.provideHandler(
            zope.component.adapter(p6.storage.events.IItemDeselected)(
                p6.api.deinstify(self.removeItem))
            )

        # enable dropping files on the list box
        XRCCTRL(self, "LST_FILES").SetDropTarget(FileDropTarget())
コード例 #16
0
ファイル: wxpy.py プロジェクト: BackupTheBerlios/cctools-svn
    def showAbout(self, event):
        return
    
        # load the dialog definition
        xrc_resource = wx.xrc.XmlResource(
            os.path.join(p6.api.getResourceDir(), 'ccpublisher.xrc'))
        about = xrc_resource.LoadDialog(None, "DLG_ABOUT")

        # set the version number
        wx.xrc.XRCCTRL(about, "LBL_VERSION").SetLabel(_("release") +
                                         str(ccpublisher.const.version()))

        # create the hyperlink label
        http_link = wx.lib.hyperlink.HyperLinkCtrl(about, -1,
                       'http://wiki.creativecommons.org/CcPublisher')

        about.GetSizer().Insert(4, http_link)
        about.Fit()
        
        # connect the events
        self.Bind(wx.EVT_BUTTON,
                  lambda event: about.Close(),
                  id = wx.xrc.XRCID("CMD_OK")
                  )
                  
        # display the dialog, then destroy it
        about.ShowModal()
        about.Destroy()
コード例 #17
0
def validateTitle(title):
    """A title must be supplied for Works."""
    
    if not(title) or not(title.strip()):
        return _("You must supply a title.")
    else:
        return None
コード例 #18
0
ファイル: cch.py プロジェクト: BackupTheBerlios/cctools-svn
	def init(self):

		self.__options = []
		self.GetSizer().Clear(True)
		self.Fit()

		#get a list of submission types and their links
		try:
			list =  pycchost.type.getSubmissionTypes(self.storage.location, self.storage.Request, self.storage.urlopen)
		except IOError, e:
			list = []
	    		if hasattr(e, 'reason'):
	        	    raise p6.extension.exceptions.ExtensionSettingsException(
	                        _("Failed to open the URL.\nThe error reason: %s.\nThis usually means the server doesn't exist, is down, or we don't have an internet connection." % e.reason))
	    		else:
			    raise p6.extension.exceptions.ExtensionSettingsException(
                    		_("Failed to open the URL. This usually means the server doesn't exist, is down, or we don't have an internet connection."))
コード例 #19
0
    def __init__(self, parent, storage):
        ccwx.xrcwiz.XrcWizPage.__init__(self, parent,
                                        os.path.join(p6.api.getResourceDir(),
                                                     "ccpublisher.xrc"),
                                        'FLICKR_COMPLETE', _('Uploading...'))


        self.__storage = storage
コード例 #20
0
    def __init__(self, parent):
        ccwx.xrcwiz.XrcWizPage.__init__(self, parent,
                                        os.path.join(p6.api.getResourceDir(),
                                                     "ccpublisher.xrc"),
                                        'CCTAG_WELCOME', _('Welcome'))

        # connect the How Does This Work button
        self.Bind(wx.EVT_BUTTON, self.onHelp, XRCCTRL(self, "HELP_WHAT_TYPES"))
コード例 #21
0
    def __init__(self, parent, metaGroup):
        p6.ui.wizard.XRCWizardPage.__init__(self, parent, _(metaGroup.title),
                                        self.PAGE_XRC % metaGroup.id,
                                        metaGroup.id
                                        )

        self.metagroup = metaGroup
        self.initFields(metaGroup)
コード例 #22
0
ファイル: ia.py プロジェクト: BackupTheBerlios/cctools-svn
    def callback(self, value_dict):

        # make sure both a username and password were provided
        if not('username' in value_dict and 'password' in value_dict):
            raise p6.extension.exceptions.ExtensionSettingsException(
                "You must supply both a username and password.")

        # validate the credentials with IA
        try:
            if not(pyarchive.user.validate(value_dict['username'],
                                           value_dict['password'])):

                raise p6.extension.exceptions.ExtensionSettingsException(
                    _("Invalid username or password."))
        except (socket.error, pyarchive.exceptions.CommunicationsError), e:
            raise p6.extension.exceptions.ExtensionSettingsException(
                _("Unable to connect to the Internet Archive to verify username and password."))
コード例 #23
0
    def __init__(self, parent, metaGroup):
        ccwx.xrcwiz.XrcWizPage.__init__(self, parent,
                                        self.PAGE_XRC % metaGroup.id,
                                        metaGroup.id,
                                        _(metaGroup.title))

        self.metagroup = metaGroup
        self.initFields(metaGroup)
コード例 #24
0
ファイル: cch.py プロジェクト: BackupTheBerlios/cctools-svn
    def __init__(self, parent, storage):
        url = p6.metadata.persistance.load("cch", "url", "")

        fields = [
            p6.metadata.base.metadatafield(p6.metadata.types.ITextField)(
            'url', 'CCHost Installation URL', default=url)
            ]
        description=_("Enter CCHost Installation's URL. For example: http://www.ccmixter.org/")

        p6.ui.pages.fieldrender.SimpleFieldPage.__init__(self,
                                                         parent,
                                                         'CCHost_LOCATION',
                                                   _('CCHost Installation URL'),
                                                         fields,
                                                         self.callback,
                                                         description)
        self.storage = storage
コード例 #25
0
ファイル: cch.py プロジェクト: BackupTheBerlios/cctools-svn
	def init(self, values=None):
		self.sizer.Clear(True)
		self.sw.Fit()
		self.sizer.AddGrowableCol(0)
		self.sizer.AddGrowableCol(1)
		row = 0

		#get a list of requested submission information
		try:
			form =  pycchost.form.getForm(self.storage.submissionlink, self.storage.Request, self.storage.urlopen, values)
		except IOError, e:
			form= []
	    		if hasattr(e, 'reason'):
	        	    raise p6.extension.exceptions.ExtensionSettingsException(
	                        _("Failed to open the URL.\nThe error reason: %s.\nThis usually means the server doesn't exist, is down, or we don't have an internet connection." % e.reason))
	    		else:
			    raise p6.extension.exceptions.ExtensionSettingsException(
                    		_("Failed to open the URL. This usually means the server doesn't exist, is down, or we don't have an internet connection."))
コード例 #26
0
        def __init__(self, parent):
            wx.ComboBox.__init__(self, parent,
                                 style=wx.CB_READONLY)
            # XXX we should support type-ahead find here

            # append each item to the list, associating each translated
            # item with it's message id
            for choice in field.choices:
                self.Append(_(choice), choice)
コード例 #27
0
ファイル: ia.py プロジェクト: BackupTheBerlios/cctools-svn
    def onChanging(self, event):
        """Validate the proposed identifier."""

        archive_id = XRCCTRL(self, "TXT_IDENTIFIER").GetValue()

        if not(pyarchive.identifier.conforms(archive_id)):
            p6.api.showError(
                _("That identifier does not conform to the "
                "Internet Archive's naming standards.") )
            event.Veto()

        if not(pyarchive.identifier.available(archive_id)):
            p6.api.showError(
                _("That identifier is not available.") )
            event.Veto()

        # both tests pass -- store the identifier
        self.storage.identifier = archive_id
コード例 #28
0
    def __init__(self, parent, storage):
        p6.ui.wizard.XRCWizardPage.__init__(self, parent, _('Complete'),
                                        os.path.join(p6.api.getResourceDir(),
                                                     "ccpublisher.xrc"),
                                        'SELFHOST_COMPLETE')

        # connect the Save button handler
        self.Bind(wx.EVT_BUTTON, self.onSave, XRCCTRL(self, "CMD_SAVE_RDF"))

        self.__storage = storage
コード例 #29
0
    def initFields(self, fields):
        """Create the user input widgets for this group."""

        # add any description text
        self.GetSizer().Add(wx.StaticText(self, -1, _(self.__description)))
            
        # create the actual sizer to hold the labels and widgets
        item_sizer = wx.FlexGridSizer(cols=2)
        item_sizer.AddGrowableCol(1)
        self.GetSizer().Add(item_sizer, flag=wx.EXPAND)

        self.addFields(fields, item_sizer)
コード例 #30
0
    def onSave(self, event):
        """Allow the user to save the RDF block."""

        saveDialog = wx.FileDialog(self, style=wx.SAVE|wx.OVERWRITE_PROMPT,
                                   wildcard="HTML (*.html)|*.html|"
                                            "Text files (*.txt)|*.txt")
        if (saveDialog.ShowModal() == wx.ID_OK):
            try:
                file(saveDialog.GetPath(), 'w').write(
                    XRCCTRL(self, "TXT_RDF").GetValue())
            except IOError, e:
                p6.api.showError( _("Unable to write to the selected file."))