How to name project script modules properly?

Hi All
I had strange problem with message “attributeerror - object has not attribute getlogger” - see screenshot below

One of my project modules was called logging which i think somehow clashed with the external library module. I rename my module from “logging” to “manual_logging” and error has disappeared.

Obviously i dont want this to happen in future so:

1 shall i in future give some project specific prefix to all modules ? it makes the name longer but if it needs to be done then it will be done
2 why did this error happened in the first place??? In call up path “_socket” library was imported which then tried to create a logger in line 56- see screenshot

3 in the folder above “_socket” there is no module called logging only there is a folder with this name - does it suggest that “_socket” module has some serious fault as it cannot find reference to logging?

4 when googling for the solution of the problem i came across discussion about getlogger issue caused by other problem than mine and somebody suggested to recompile the library which supposedly solved that problem.

Did anybody ever had to recompile anything in the ignition python library? How can this be done in theory? I am curious but dont want to touch anything in ignition\python files.

Within the Ignition execution environment, since 8.0.0, we deliberately inject all of your project scripts into the top level namespace last, meaning they’ll override whatever might have already been defined. This can cause problems, but most of the time doesn’t, and the ease of use gain is considered to trump the potential headache of collisions like this.

1 Like

hi Paul
thank you for reply but still trying to understand the internals.
Are you able to help me to understand why in “” there is reference to logging module which is not there? Also point 4 from my question if you have time please

Also i am still confused how can injecting all of the project scripts into the top level namespace last helped if my problem happened anyway :frowning:

logging is there. Inside the folder logging, there’s an descriptor that contains this line:

By defining __all__, an file can choose to expose certain members. This is all Python (2) built in stuff; nothing to do with Ignition.

For your question 4: Compilation is totally irrelevant to you in Jython. Jython does its own “compilation”, but it’s different from CPython and the error messages you may have seen while searching were almost certainly due to different underlying root causes. You can’t trigger recompilation or force it in any way in the Jython environment.

Injecting them ‘last’ isn’t specifically done to help avoid any issues; it’s just the way it is done. Python has (basically) one global namespace. If you want to refer to the standard library’s logging module, you must not have something else named logging.

1 Like

thanks a lot for answering my question and also satisfying curiosity :slight_smile:

1 Like