I need to create a new class which extends ModelSavingExceptionTranslationHandler.
When I try to write it as:
import
de.hybris.platform.platformbackoffice.services.handlers.ModelSavingExceptionTranslationHandler;
I want to know which extension does it belong to so that I configure this in extensioninfo.xml.When I configure platformbackoffice, this is still not resolved.
You can find it with IDE features. For example in IntelliJ, press Select Opened File (Alt+Shift+1, 1) button after finding class.
ModelSavingExceptionTranslationHandler class in in the platformbackoffice extenison.
Related
I am trying to load a class at run time from a configuration file. The module that contains the class will contain many other classes and I don't want to import them all. The pattern given in this question Import class from module dynamically
cls = getattr(import_module('my_module'), 'my_class')
loads in the entire module which is exactly what I am trying to avoid. Is there way to get just 'my_class' without everything else in 'my_module'?
I created two classes. The first class takes an image from the working directory and then covert the image from pdf to jpg using wand. The second class takes the created jpg image and then do further manipulations with the image.
Now When I try to run the first class and then the second class right after that; python crashes because the second class is trying to look for the image but it wont find it until it is created.
My question is how can you run the second class but just after the first class is executed.
class1 = imagecreation('image.jpg')
class2 = transformimage()
I found the answer to my question. When you reference classes and you import as a module in a different one; the module will get call when is defined if you do not use if __name__=='__main__':. By putting this code at the end of the code will only execute the module once it is intended to be executed but not when you import the module. This way you can use the modules by themselves and also to import from other modules.
I am using the gi.repository.Gtk module to generate some GUIs.
To let the user select a folder I use the gi.repository.Gtk.FileChooserButton.
According to the Gtk3 documentation I should be able to select or create folders using the action Gtk.FileChooserAction.SELECT_FOLDERor Gtk.FileChooserAction.CREATE_FOLDER.
So the relevant code is this:
filechooser = Gtk.FileChooserButton(Gtk.FileChooserAction.CREATE_FOLDER)
filechooser.connect("file-set",update_select_folder)
def update_select_folder(*args):
print(*args)
But I am still unable to select/create folders.( I am able to select files.)
Python3 Gtk3 Documentation
complete Code on github
So my Question is: How can I select/create folders using a FileChooserButton?
From https://developer.gnome.org/gtk3/stable/GtkFileChooser.html
filechooser = Gtk.FileChooserButton()
filechooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
filechooser.set_create_folders(True)
I am using a package from biopython called SubsMat, I want to override a function that is located in SubsMats __init__.py.
I tried making a class that inherits SubsMat like this:
from Bio import SubsMat
class MyOwnSubsMat(SubsMat):
but you cannot inherit a package I guess. I cannot alter the source code literally since it is a public package on the network.
Is there any workaround for a noob like me?
You can do that:
from Bio import SubsMat
SubsMat.function = my_own_replacement_for_function
But it will change the package for everyone using it.
I am modifying a module which contains a class in it.
When I %run another module that uses the mofified class from IPython, the changes do not seem to take effect unless I restart IPython.
I have tried to use imp.reload, but this does not help. For example, I have put the following the code at the top of my module, but it does not appear to be using the updated version of my modified class (BigMySQLDatabaseGetter in the big_mysql_database_getter module)
import imp
import sys
from big_mysql_database_getter import BigMySQLDatabaseGetter
module_big_mysql_database_getter = sys.modules['big_mysql_database_getter']
imp.reload(module_big_mysql_database_getter)
Reloading a module doesn't automatically update all references that were created before, it just redefines everything within the module.
So if you do something like:
from spam import eggs
imp.reload(spam)
print(spam.eggs is eggs)
you'll get False, as eggs still references the old class. Likewise, instances created before the reload are instances of the old class, not of the new class:
import spam
e = spam.eggs()
imp.reload(spam)
print(isinstance(e, spam.eggs)) # False!
In your case, you can either reimport BigMySQLDatabaseGetter after reloading the module, or instead of directly importing the class just import the module and use big_mysql_database_getter.BigMySQLDatabaseGetter instead.