[Products.SilvaExternalSources][Emiliano D'Alterio] More fixes t...

[email protected] Wed, 28 Aug 2013 18:23:57 +0200
Newsgroups gmane.comp.web.zope.silva.cvs
Message-ID <[email protected]>
author:    Emiliano D'Alterio
date:      Wed Aug 28 18:23:53 2013 +0200
revision:  1106:556f25bb3d60 in Products.SilvaExternalSources
branch:    2.4
details:   https://hg.infrae.com/Products.SilvaExternalSources?cmd=changeset;node=556f25bb3d60
modified:  Products/SilvaExternalSources/CodeSource.py Products/SilvaExternalSources/CodeSourceService.py
added:     
removed:   
log:       More fixes to the Code Source export and update functions.


diffstat:

 Products/SilvaExternalSources/CodeSource.py        |  10 ++++++----
 Products/SilvaExternalSources/CodeSourceService.py |   2 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 2c050a3aa086 -r 556f25bb3d60 Products/SilvaExternalSources/CodeSource.py
--- a/Products/SilvaExternalSources/CodeSource.py	Wed Aug 28 16:45:06 2013 +0200
+++ b/Products/SilvaExternalSources/CodeSource.py	Wed Aug 28 18:23:53 2013 +0200
@@ -243,11 +243,12 @@
         """Update a code source from the filesystem.
         """
         installable = self._get_installable()
-        if installable is None:
+        if (installable is None or
+                not os.path.isdir(installable._directory)):
             if REQUEST is not None:
                 return self.editCodeSource(
                     manage_tabs_message=\
-                        'Could find the code source on the filesystem.')
+                        'Couldn\'t find the code source on the filesystem.')
             return False
         installable.update(self, bool(purge))
         if REQUEST is not None:
@@ -261,11 +262,12 @@
         """Export a code source to the filesystem.
         """
         installable = self._get_installable()
-        if installable is None:
+        if (installable is None or
+                not os.path.isdir(installable._directory)):
             if REQUEST is not None:
                 return self.editCodeSource(
                     manage_tabs_message=\
-                        'Could find the code source on the filesystem.')
+                        'Couldn\'t find the code source on the filesystem.')
             return None
         directory = None
         if aszip:
diff -r 2c050a3aa086 -r 556f25bb3d60 Products/SilvaExternalSources/CodeSourceService.py
--- a/Products/SilvaExternalSources/CodeSourceService.py	Wed Aug 28 16:45:06 2013 +0200
+++ b/Products/SilvaExternalSources/CodeSourceService.py	Wed Aug 28 18:23:53 2013 +0200
@@ -387,6 +387,8 @@
         return self.update(source)
 
     def _get_installables(self):
+        if not os.path.isdir(self._directory):
+            return
         for filename in os.listdir(self._directory):
             if filename == CONFIGURATION_FILE or filename.startswith('.'):
                 continue