From f629f2b32340df19b6ef205e0a328d967c7d5326 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Wed, 5 Mar 2014 16:48:54 +0100 Subject: [PATCH] [gen] Removed obsolete function to create objects via an import form. --- gen/__init__.py | 34 ++--------- gen/mixins/ToolMixin.py | 66 ++------------------- gen/tr/Appy.pot | 24 -------- gen/tr/ar.po | 24 -------- gen/tr/de.po | 24 -------- gen/tr/en.po | 24 -------- gen/tr/es.po | 24 -------- gen/tr/fr.po | 24 -------- gen/tr/it.po | 24 -------- gen/tr/nl.po | 24 -------- gen/ui/appy.js | 5 -- gen/ui/buttonImport.png | Bin 766 -> 0 bytes gen/ui/eye.png | Bin 372 -> 0 bytes gen/ui/select_elems.png | Bin 235 -> 0 bytes gen/wrappers/ToolWrapper.py | 112 ------------------------------------ 15 files changed, 10 insertions(+), 399 deletions(-) delete mode 100644 gen/ui/buttonImport.png delete mode 100644 gen/ui/eye.png delete mode 100644 gen/ui/select_elems.png diff --git a/gen/__init__.py b/gen/__init__.py index 9414774..021aef7 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -40,43 +40,17 @@ from appy.fields.workflow import * from appy.gen.layout import Table from appy.gen.utils import No -# Make the following classes available here: people may need to monkey-patch -# some PXs on thoses classes. +# Make the following classes available here: people may need to override some +# of their PXs (defined as static attributes). from appy.gen.wrappers import AbstractWrapper as BaseObject from appy.gen.wrappers.ToolWrapper import ToolWrapper as BaseTool -class Import: - '''Used for describing the place where to find the data to use for creating - an object.''' - def __init__(self, path, onElement=None, headers=(), sort=None): - self.id = 'import' - self.path = path - # p_onElement hereafter must be a function (or a static method) that - # will be called every time an element to import is found. It takes a - # single arg that is the absolute filen name of the file to import, - # within p_path. It must return a list of info about the element, or - # None if the element must be ignored. The list will be used to display - # information about the element in a tabular form. - self.onElement = onElement - # The following attribute must contain the names of the column headers - # of the table that will display elements to import (retrieved from - # calls to self.onElement). Every not-None element retrieved from - # self.onElement must have the same length as self.headers. - self.headers = headers - # The following attribute must store a function or static method that - # will be used to sort elements to import. It will be called with a - # single param containing the list of all not-None elements as retrieved - # by calls to self.onElement (but with one additional first element in - # every list, which is the absolute file name of the element to import) - # and must return a similar, sorted, list. - self.sort = sort - # ------------------------------------------------------------------------------ class Model: pass class Tool(Model): - '''If you want to extend or modify the Tool class, subclass me.''' + '''Subclass me to extend or modify the Tool class.''' class User(Model): - '''If you want to extend or modify the User class, subclass me.''' + '''Subclass me to extend or modify the User class.''' # ------------------------------------------------------------------------------ class LdapConfig: diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py index 8f90f90..57b92c6 100644 --- a/gen/mixins/ToolMixin.py +++ b/gen/mixins/ToolMixin.py @@ -260,28 +260,6 @@ class ToolMixin(BaseMixin): klass = self.getAppyClass(className) return getattr(klass, 'resultMode', 'list') - def getImportElements(self, className): - '''Returns the list of elements that can be imported from p_path for - p_className.''' - appyClass = self.getAppyClass(className) - importParams = self.getCreateMeans(appyClass)['import'] - onElement = importParams.onElement.__get__('') - sortMethod = importParams.sort - if sortMethod: sortMethod = sortMethod.__get__('') - elems = [] - importType = self.getAppyType('importPathFor%s' % className) - importPath = importType.getValue(self) - for elem in os.listdir(importPath): - elemFullPath = os.path.join(importPath, elem) - elemInfo = onElement(elemFullPath) - if elemInfo: - elemInfo.insert(0, elemFullPath) # To the result, I add the full - # path of the elem, which will not be shown. - elems.append(elemInfo) - if sortMethod: - elems = sortMethod(elems) - return [importParams.headers, elems] - def showPortlet(self, obj, layoutType): '''When must the portlet be shown? p_obj and p_layoutType can be None if we are not browing any objet (ie, we are on the home page).''' @@ -484,26 +462,16 @@ class ToolMixin(BaseMixin): return self.getProductConfig().allClassNames + [self.__class__.__name__] def getCreateMeans(self, klass): - '''Gets the different ways objects of p_klass can be created (via a web - form, by importing external data, etc). Result is a dict whose keys - are strings (ie "form", "import"...) and whose values are additional - data about the particular mean.''' - res = {} + '''Gets the different ways objects of p_klass can be created (currently: + via a web form or programmatically only). Result is a list.''' + res = [] if not klass.__dict__.has_key('create'): - res['form'] = None - # No additional data for this means, which is the default one. + return ['form'] else: means = pythonClass.create if means: - if isinstance(means, basestring): res[means] = None - elif isinstance(means, list) or isinstance(means, tuple): - for mean in means: - if isinstance(mean, basestring): - res[mean] = None - else: - res[mean.id] = mean - else: - res[means.id] = means + if isinstance(means, basestring): res = [means] + else: res = means return res def userMaySearch(self, klass): @@ -541,28 +509,6 @@ class ToolMixin(BaseMixin): if role in creators: return True - def onImportObjects(self): - '''This method is called when the user wants to create objects from - external data.''' - rq = self.REQUEST - appyClass = self.getAppyClass(rq.get('className')) - importPaths = rq.get('importPath').split('|') - appFolder = self.getPath('/data') - for importPath in importPaths: - if not importPath: continue - objectId = os.path.basename(importPath) - self.appy().create(appyClass, id=objectId, _data=importPath) - self.say(self.translate('import_done')) - return self.goto(rq['HTTP_REFERER']) - - def isAlreadyImported(self, contentType, importPath): - data = self.getPath('/data') - objectId = os.path.basename(importPath) - if hasattr(data.aq_base, objectId): - return True - else: - return False - def isSortable(self, name, className, usage): '''Is field p_name defined on p_className sortable for p_usage purposes (p_usage can be "ref" or "search")?''' diff --git a/gen/tr/Appy.pot b/gen/tr/Appy.pot index 2dc8ebe..eca9569 100644 --- a/gen/tr/Appy.pot +++ b/gen/tr/Appy.pot @@ -103,10 +103,6 @@ msgstr "" msgid "query_create" msgstr "" -#. Default: "import" -msgid "query_import" -msgstr "" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "" @@ -115,26 +111,6 @@ msgstr "" msgid "query_consult_all" msgstr "" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "" - -#. Default: "Already imported." -msgid "import_already" -msgstr "" - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "" - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "" - #. Default: "Advanced search" msgid "search_title" msgstr "" diff --git a/gen/tr/ar.po b/gen/tr/ar.po index b35ea55..7d37d11 100644 --- a/gen/tr/ar.po +++ b/gen/tr/ar.po @@ -103,10 +103,6 @@ msgstr "" msgid "query_create" msgstr "" -#. Default: "import" -msgid "query_import" -msgstr "" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "" @@ -115,26 +111,6 @@ msgstr "" msgid "query_consult_all" msgstr "" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "" - -#. Default: "Already imported." -msgid "import_already" -msgstr "" - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "" - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "" - #. Default: "Advanced search" msgid "search_title" msgstr "" diff --git a/gen/tr/de.po b/gen/tr/de.po index dad9024..5b66b47 100644 --- a/gen/tr/de.po +++ b/gen/tr/de.po @@ -103,10 +103,6 @@ msgstr "Nach unten verschieben" msgid "query_create" msgstr "Anfertigen" -#. Default: "import" -msgid "query_import" -msgstr "Importieren" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "Kein Resultat" @@ -115,26 +111,6 @@ msgstr "Kein Resultat" msgid "query_consult_all" msgstr "Alles untersuchen" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "Angaben importieren" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "Zeigen / verbergen von bereits importierten Elementen." - -#. Default: "Already imported." -msgid "import_already" -msgstr "Bereits importiert." - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "Ausgewählte Elemente importieren." - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "Das Importieren ist erfolgt." - #. Default: "Advanced search" msgid "search_title" msgstr "Fortgeschrittene Suche" diff --git a/gen/tr/en.po b/gen/tr/en.po index f11df9a..5b4efeb 100644 --- a/gen/tr/en.po +++ b/gen/tr/en.po @@ -104,10 +104,6 @@ msgstr "Move down" msgid "query_create" msgstr "create" -#. Default: "import" -msgid "query_import" -msgstr "import" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "Nothing to see for the moment." @@ -116,26 +112,6 @@ msgstr "Nothing to see for the moment." msgid "query_consult_all" msgstr "consult all" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "Importing data into your application" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "Show / hide alreadly imported elements." - -#. Default: "Already imported." -msgid "import_already" -msgstr "Already imported." - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "Import selected elements" - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "Import terminated successfully." - #. Default: "Advanced search" msgid "search_title" msgstr "Advanced search" diff --git a/gen/tr/es.po b/gen/tr/es.po index 50552d7..77ec0f5 100644 --- a/gen/tr/es.po +++ b/gen/tr/es.po @@ -103,10 +103,6 @@ msgstr "Mueva hacia abajo" msgid "query_create" msgstr "Crear" -#. Default: "import" -msgid "query_import" -msgstr "Importar" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "No hay resultados." @@ -115,26 +111,6 @@ msgstr "No hay resultados." msgid "query_consult_all" msgstr "Consultar todo" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "Importar datos" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "Mostrar / ocultar los elementos ya importados." - -#. Default: "Already imported." -msgid "import_already" -msgstr "Ya importado." - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "Importar los elementos seleccionados." - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "La importación se ha desarrollado con éxito" - #. Default: "Advanced search" msgid "search_title" msgstr "Búsqueda avanzada" diff --git a/gen/tr/fr.po b/gen/tr/fr.po index 07d1c68..6d7371b 100644 --- a/gen/tr/fr.po +++ b/gen/tr/fr.po @@ -104,10 +104,6 @@ msgstr "Déplacer vers le bas" msgid "query_create" msgstr "Créer" -#. Default: "import" -msgid "query_import" -msgstr "Importer" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "Pas de résultat." @@ -116,26 +112,6 @@ msgstr "Pas de résultat." msgid "query_consult_all" msgstr "Tout consulter" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "Importer des données" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "Montrer / cacher les éléments déjà importés." - -#. Default: "Already imported." -msgid "import_already" -msgstr "Déjà importé." - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "Importer les éléments sélectionnés." - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "L'importation s'est déroulée avec succès" - #. Default: "Advanced search" msgid "search_title" msgstr "Recherche avancée" diff --git a/gen/tr/it.po b/gen/tr/it.po index e5bcc8f..ae52f23 100644 --- a/gen/tr/it.po +++ b/gen/tr/it.po @@ -103,10 +103,6 @@ msgstr "Giù" msgid "query_create" msgstr "Creazione in corso" -#. Default: "import" -msgid "query_import" -msgstr "Import" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "Nessun risultato" @@ -115,26 +111,6 @@ msgstr "Nessun risultato" msgid "query_consult_all" msgstr "Consultare tutto" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "Importare i dati" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "Evidenzia / nascondi gli elementi già importati." - -#. Default: "Already imported." -msgid "import_already" -msgstr "Già importati" - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "Importare gli elementi selezionati." - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "Import è terminato con successo" - #. Default: "Advanced search" msgid "search_title" msgstr "Ricerca avanzata" diff --git a/gen/tr/nl.po b/gen/tr/nl.po index 65a0f2e..96c04dc 100644 --- a/gen/tr/nl.po +++ b/gen/tr/nl.po @@ -103,10 +103,6 @@ msgstr "Verplaats naar beneden" msgid "query_create" msgstr "Aanmaken" -#. Default: "import" -msgid "query_import" -msgstr "Importeren" - #. Default: "Nothing to see for the moment." msgid "query_no_result" msgstr "Geen resultaat" @@ -115,26 +111,6 @@ msgstr "Geen resultaat" msgid "query_consult_all" msgstr "Alles raadplegen" -#. Default: "Importing data into your application" -msgid "import_title" -msgstr "Gegevens importeren" - -#. Default: "Show / hide alreadly imported elements." -msgid "import_show_hide" -msgstr "Tonen / verbergen van reeds geïmporteerde elementen." - -#. Default: "Already imported." -msgid "import_already" -msgstr "Reeds geïmporteerd." - -#. Default: "Import selected elements" -msgid "import_many" -msgstr "Geselecteerde elementen importeren." - -#. Default: "Import terminated successfully." -msgid "import_done" -msgstr "Het importeren is met succes afgelopen." - #. Default: "Advanced search" msgid "search_title" msgstr "Gevorderde opzoeking" diff --git a/gen/ui/appy.js b/gen/ui/appy.js index 2101644..6731d38 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -238,11 +238,6 @@ function askRefField(hookId, objectUrl, fieldName, innerRef, startNumber, askAjaxChunk(hookId, 'GET', objectUrl, fieldName+':pxView', params); } -function askComputedField(hookId, objectUrl, fieldName) { - // Sends an Ajax request for getting the content of a computed field - askAjaxChunk(hookId, 'GET', objectUrl, fieldName+':pxViewContent'); -} - function askField(hookId, objectUrl, layoutType, showChanges, masterValues, requestValue, error, className){ // Sends an Ajax request for getting the content of any field. diff --git a/gen/ui/buttonImport.png b/gen/ui/buttonImport.png deleted file mode 100644 index ce45d2aba41c20b98234a5630c6625f259e72098..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmVFu_k00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*o4 z4>&mV2$MNUa=Jsuqxuswz{g^UhEXo;yQiR|wVhSFm zL-q&MQAE77=v1dV?BLalbqmC~pl?uMkUJ(gZL)olmbJCM+uV0^>(CFdpf=qldOuFz z!}oi6@#g)0^WpPVYPA|dG+T>AAf&LwKf|Kyy39h+R6RXCisk!*q#>F@*Y$55>mVOr z)dpy_D%khh>9%>fe=#hHio@?%B_+@BxigGi8YH4Wl@!H3nx@qn>R7j8H+ffhi)mIU zl}hAVvg{ZcNmBg2yf^Z4xl&=+-%Hs%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303330..3b3e269 100644 --- a/gen/wrappers/ToolWrapper.py +++ b/gen/wrappers/ToolWrapper.py @@ -187,7 +187,6 @@ class ToolWrapper(AbstractWrapper): - - - - - @@ -534,109 +525,6 @@ class ToolWrapper(AbstractWrapper): ''', template=AbstractWrapper.pxTemplate, hook='content') - pxImport = Px(''' - - :tool.pxPagePrologue - - - -
- - - -
- -

:_('import_title')


- - - - - - - - - - - - - -
- - :columnHeader -
:elem - - :_('import_already') - - -
:_('query_no_result')
- - -


- -

-
''', template=AbstractWrapper.pxTemplate, hook='content') - def isManager(self): '''Some pages on the tool can only be accessed by managers.''' if self.user.has_role('Manager'): return 'view'