Weird conflict with deploy of django project with django_assets - django

recently I've tried to add webassets to my django project. All goes without any problem in development (with django runserver). All js and css are beign compressed when I set the settings var ASSETS_DEBUG to False.
The problem arises when I browse my project from my deployed structure (apache + mod_wsgi). An exception is raised from django_assets giving me the following message:
RegisterError: Another bundle is already registered as "js_all": ], contents=('js/jquery-1.6.3.min.js', 'js/jquery-ui-1.8.16.custom.min.js', 'js/jquery-ui-timepicker-addon.js', 'js/ui.datepicker-es.js', 'js/tiny_mce/tiny_mce.js', 'js/tiny_mce_config.js', 'js/public.js')>
Can't find the reason for this exception, not thrown in development. Following is my assets file:
from django_assets import Bundle, register
js = Bundle(
'js/jquery-1.6.3.min.js',
'js/jquery-ui-1.8.16.custom.min.js',
'js/jquery-ui-timepicker-addon.js',
'js/ui.datepicker-es.js',
'js/tiny_mce/tiny_mce.js',
'js/tiny_mce_config.js',
'js/public.js',
filters='yui_js',
output='js/gen/packed.js'
)
register('js_all', js)
css = Bundle(
'css/smoothness/jquery-ui-1.8.16.custom.css',
'css/jquery_ui_fixes.css',
'css/public.css',
'css/forms.css',
filters='yui_css',
output='css/gen/packed.css',
)
register('css_all', css)
Webassets version used is the one in pip repository:
version = (0, 6)
I hope that somebody will be able to help me.
Isaac

Because of some silliness with Django, your settings.py file can be imported twice. Thus registration will occur twice. Read:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html
for all the horrible details of this issue.

Related

ember-electron application start (code hierarchy)

I'm trying to move a very old 2.x ember-electron application to new electron with ember-electron and got application window with blank screen and error in console:
(node:9061) electron: Failed to load URL: serve://dist/ with error: ERR_FILE_NOT_FOUND
The calling file ../new-ember-electron/electron-app/src/index.js has lines from old applications:
const emberAppLocation = 'serve://dist';
mainWindow.loadURL(emberAppLocation);
File ../new-ember-electron/app/router.js has:
this.route('index', { path: '/' }, function() {}
Files ../new-ember-electron/app/routes/index.js, ../new-ember-electron/app/controllers/index.js and ../new-ember-electron/app/templates/index.hbs also exist.
So, it's unclear what exactly is not found and how to find a more detailed error (application developer console doesn't have errors). But if to change the mentioned 2 lines in ../new-ember-electron/electron-app/src/index.js to:
const emberAppLocation = '../app/index.html';
mainWindow.loadFile(emberAppLocation);
then application shows content of the correct file, despite nothing working in it, even <LinkTo>...</LinkTo> is not treated as a link.
Would you please help me to understand how an ember-electron application should be structured and which way is called for the recent versions?
Used versions: node - 16.14.0, electron: 17.0.1, ember-cli: 3.28.5, ember-electron: 3.1.0, OS: darwin x64.
Thank you.
Thank you, jacobq, I've looked at your example and used emberAppUrl to start from ember-dist/index.html file. After few more changes related to require/requireNode (fixed with webPreferences options in mainWindow) the app rendered index.html file. But a problem with app location happens again right on {{ content-for "body" }} in index.html: "Uncaught Error: Cannot find module 'app-name/app'" where app-name is the application name set up as 'name' in /package.json and as 'modulePrefix' in config/environment.js. The error itself comes from /node-modules/ember-cli/lib/utilities/ember-app-utils.js, 'contentFor' function called with 'app-boot'. The ember-cli itself constructs the /app-name/app path. So, the question now is what exactly ember-cli expects to find during the boot with the new structure? Or maybe some config variable should be added to let know Ember about the /app-name/app location?
Edited:
jacobq, yes, the only difference in index.html is application name: "testapp". RootURL is set in ../testapp/config/environment.js:
podModulePrefix: 'testapp/pods',
environment,
modulePrefix: 'testapp',
rootURL: process.env.EMBER_CLI_ELECTRON ? '' : '/',
locationType: process.env.EMBER_CLI_ELECTRON ? 'hash' : 'auto',
The full error:
It happens when testapp.js file is called from index.html, on code included from ember-cli:
if (!runningTests) {
require("testapp/app")["default"].create({"LOG_TRANSITIONS":true,"LOG_TRANSITIONS_INTERNAL":true});
}
First thing I'd like to plug is joining the #topic-desktop channel on the Ember.js community Discord server: https://discord.com/channels/480462759797063690/488735754139336714
(it's often easier to work things out by chatting there as there's lower latency than typically found with forum post/reply platforms)
Secondly, there are lots of breaking (but good) changes between ember-electron 2.x and 3.x, so I'd encourage you to work through the upgrade guide here: https://ember-electron.js.org/docs/guides/upgrading
That said, I suspect that the problem you're seeing is related to the change from serve:// to file://. Have a look at the demo app I just spun up here:
https://github.com/jacobq/ember-electron-demo
You can see the new emberAppURL here:
https://github.com/jacobq/ember-electron-demo/blob/cf7c5dee2cd975f8c67ed1dfc61eb717461f5b7d/electron-app/src/index.js#L13
Basically, ember-electron v3.x puts the usual dist output from ember build into <project_root>/electron-app/ember-dist/ now.
FWIW, I'm actually stuck on 3.0.0-beta.2 in my application because I am using IndexedDB and don't have migration code to deal with origin-related issues of switching to file:// scheme. I don't recommend that you use that version, but you could try it if you wanted to see if that changes the error you're encountering (because that beta still uses electron-protocol-serve).

Django CkEditor Load Custom Plugin - Not Working

I'm creating a custom CkEditor for Django. I followed https://ckeditor.com/docs/ckeditor4/latest/guide/plugin_sdk_sample_1.html and tried to load the plugin but it doesn't. When I put other plugins into my static folder (lib/static/ckeditor/ckeditor/plugins/MYPLUGIN) and try to load them, it works.
Maybe someone can help me.
Console error:
ckeditor.js:98 GET http://127.0.0.1:8000/lib/static/ckeditor/ckeditor/plugins/utils/plugin.js?t=I3I8 net::ERR_ABORTED 404 (Not Found)
ckeditor.js:255 Uncaught Error: [CKEDITOR.resourceManager.load] Resource name "utils" was not found at "http://127.0.0.1:8000/lib/static/ckeditor/ckeditor/plugins/utils/plugin.js?t=I3I8".
at CKEDITOR.resourceManager.<anonymous> (ckeditor.js:255)
at e (ckeditor.js:250)
at Array.z (ckeditor.js:250)
at y (ckeditor.js:250)
at ckeditor.js:251
Problem solved
I accidentally named plugin.js plugins.js (with s).

Redmine_RE plugin is not saving the data

i am using the Redmine.3.1.0.Then i have installed redmine_re plugin.But when i try to save the requirement using the Redmine_re plugin i am getting the following error
NameError (undefined local variable or method `connection' for #<ReArtifactRelationship:0x800ddb0>):
lib/plugins/acts_as_list/lib/active_record/acts/list.rb:220:in `bottom_item'
lib/plugins/acts_as_list/lib/active_record/acts/list.rb:214:in `bottom_position_in_list'
lib/plugins/acts_as_list/lib/active_record/acts/list.rb:205:in `add_to_list_bottom'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
pls suggest how to resolve this error
#ste26054
I did not develop this plugin, but I think the support for redmine 3.1.0 is only partial at the moment. (And you may get other errors even after fixing this).
I believe you are getting an error because of this: Deprecate #connection in favour of accessing it via the class
And your error is related to this file:
In this method:
def scope_condition()
"#{connection.quote_column_name("source_id")} = #{quote_value(self.source_id)}
AND
#{connection.quote_column_name("relation_type")} = #{quote_value(self.relation_type)}"
end
Try to add self.class. in front of connection
You may have to repeat this for other files in the code.
If your changes are working, I would suggest you to submit a pull request on their plugin github page :)

magento Not valid template file /page/1column.phtml

I had my site running fine on the devp. server. After I migrated the app to my production server. Everything worked until I added an extension and enabled it. The site still works but the product view page doesn't show up. Everytime I click on the product view page, this error is appended to my log file...
CRIT (2): Not valid template file:frontend/base/default/template/page/1column.phtml
I have checked the file it is alright, just same as the one working on the development server. I've tried disabling the only plugin (custom menu) that I have and still the problem persists. I've tried increasing memory_limit but it doesn't help either.
Please help, I am stuck in the middle of nothing.
A common cause of this error is the use of symlinks without enabling this in the admin area…
System > configuration > developer > Template Settings
The error gets triggered in app\code\core\Mage\Core\Block\Template.php around line 243 ( see here ) - so if its not an issue with symlinks then this would be a good place to start debugging.
If you are not using xDebug then where the exception gets caught around line 250 you should either log or var_dump the values of:
$includeFilePath
and
$this->_viewDir
Then make sure they both exist (paying attention to the case)
Failing that you might want to look at permissions.
UPDATE core_config_data SET value = '1' WHERE path = 'dev/template/allow_symlink';
or
INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0, 'dev/template/allow_symlink', '1');

Embed jetty in java app and export as jar

I'm making a java application which embeds a Jetty web server, which in turn serves content developed with Google Web Toolkit. It's all working fine when run in Eclipse, but when I export it as a jar file all I get is a Jetty error message saying "File not found".
The Jetty server is launched like this:
WebAppContext handler = new WebAppContext();
handler.setResourceBase("./war");
handler.setDescriptor("./war/WEB-INF/web.xml");
handler.setContextPath("/");
handler.setParentLoaderPriority(true);
server.setHandler(handler);
try {
server.start();
server.join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I suspect that the problem is the relative paths used in handler.setResourceBase() and handler.setDescriptor(). I've googled and tested lots of solutions to this but so far to no avail. Particularly I've tried using something like getClass().getResource("./war").toExternalForm() but this just throws Null exceptions.
I also tried:
ProtectionDomain protectionDomain = Start.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
but that only results in a Jetty serving a directory listing of the java classes.
Is there any way to do this?
Copy all files of the compiled GWT application into one of your Java packages. For instance:
my.webapp.resources
html/MyPage.html
gwtmodule/gwtmodule.nocache.js
...
(html, gwtmodule will become Java packages as well).
Configure the embedded Jetty instance to serve these files.
final String webDir = this.getClass().
getClassLoader().getResource("my/webapp/resources").toExternalForm();
final Context root = new Context(server, "/", Context.SESSIONS);
root.setContextPath("/");
root.setResourceBase(webDir);
root.addServlet(MyGwtService.class, "/servlets/v01/gwtservice");
This approach works for me both when the application is run from eclipse as well as when it is deployed.
I've posted a detailed description on how to do this here:
http://h30499.www3.hp.com/t5/HP-Software-Developers-Blog/Embedding-Jetty-in-a-Java-Main-Application/ba-p/6107503
It looks like ClassLoader.getResource does not understand an empty string or . or / as an argument. In my jar file I had to move all stuf to WEB-INF. So the code looks like
`contextHandler.setResourceBase(EmbeddedJetty.class.getClassLoader().getResource("WEB-INF").toExternalForm());`
so the context looks like this then:
ContextHandler:744 - Started o.e.j.w.WebAppContext#48b3806{/,jar:file:/Users/xxx/projects/dropbox/ui/target/ui-1.0-SNAPSHOT.jar!/WEB-INF,AVAILABLE}