Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

# coding: utf-8 

 

""" 

PyLucid base settings 

~~~~~~~~~~~~~~~~~~~~~ 

""" 

 

from pathlib import Path 

 

from django.utils.translation import ugettext_lazy as _ 

 

 

# Quick-start development settings - unsuitable for production 

# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ 

 

# SECURITY WARNING: don't run with debug turned on in production! 

DEBUG = False 

 

SITE_ID=1 

 

 

from django_tools.settings_utils import FnMatchIps 

 

# Required for the debug toolbar to be displayed: 

INTERNAL_IPS = FnMatchIps(["localhost", "127.0.0.1", "::1", "172.*.*.*", "192.168.*.*", "10.0.*.*"]) 

 

ALLOWED_HOSTS = INTERNAL_IPS 

 

 

# Application definition 

 

INSTALLED_APPS = ( 

'djangocms_admin_style', # must be inserted before django.contrib.admin 

 

'django.contrib.admin', 

'django.contrib.auth', 

'django.contrib.contenttypes', 

'django.contrib.sessions', 

'django.contrib.messages', 

'django.contrib.staticfiles', 

'django.contrib.sites', 

 

'debug_toolbar', # https://github.com/jazzband/django-debug-toolbar/ 

 

'compressor', # https://github.com/django-compressor/django-compressor 

 

'cms', # https://github.com/divio/django-cms 

'menus', # Part of Django-CMS 

 

'djangocms_history', # https://github.com/divio/djangocms-history 

 

'treebeard', # https://github.com/django-treebeard/django-treebeard 

'sekizai', # https://github.com/ojii/django-sekizai 

'djangocms_text_ckeditor', # https://github.com/divio/djangocms-text-ckeditor 

 

# TODO: remove if migration from 'cmsplugin_filer_link' to 'djangocms-link' is done: 

# http://docs.django-cms.org/en/latest/topics/commonly_used_plugins.html#deprecated-addons 

'cmsplugin_filer_link', 

 

'cmsplugin_pygments', # https://github.com/chrisglass/cmsplugin-pygments 

'cmsplugin_markup', # https://github.com/mitar/cmsplugin-markup 

 

'djangocms_htmlsitemap', # https://github.com/kapt-labs/djangocms-htmlsitemap 

 

# djangocms-blog dependencies, see: https://djangocms-blog.readthedocs.io/en/latest/installation.html 

'filer', # https://github.com/divio/django-filer 

'easy_thumbnails', # https://github.com/SmileyChris/easy-thumbnails 

'aldryn_apphooks_config', 

'cmsplugin_filer_image', 

'parler', # https://pypi.org/project/django-parler 

'taggit', 

'taggit_autosuggest', 

'meta', # https://github.com/nephila/django-meta 

'djangocms_blog', 

 

 

# https://github.com/jedie/django-cms-tools/ 

'django_cms_tools', 

'django_cms_tools.filer_tools', 

'django_cms_tools.plugin_anchor_menu', 

# 'django_cms_tools.plugin_landing_page', # TODO: Needs publisher! 

 

'pylucid', 

# 'pylucid_todo', # Only needed for old migrated installations 

 

# Installed only in developer installation: 

#'django_extensions', # https://github.com/django-extensions/django-extensions 

) 

 

ROOT_URLCONF = 'pylucid_page_instance.urls' 

WSGI_APPLICATION = 'pylucid_page_instance.wsgi.application' 

 

MIDDLEWARE = ( 

'django.middleware.cache.UpdateCacheMiddleware', 

 

# https://github.com/jazzband/django-debug-toolbar/ 

'debug_toolbar.middleware.DebugToolbarMiddleware', 

 

'cms.middleware.utils.ApphookReloadMiddleware', 

'django.contrib.sessions.middleware.SessionMiddleware', 

'django.middleware.locale.LocaleMiddleware', 

'django.middleware.common.CommonMiddleware', 

'django.middleware.csrf.CsrfViewMiddleware', 

'django.contrib.auth.middleware.AuthenticationMiddleware', 

'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 

'django.contrib.messages.middleware.MessageMiddleware', 

'django.middleware.clickjacking.XFrameOptionsMiddleware', 

'django.middleware.security.SecurityMiddleware', 

'cms.middleware.user.CurrentUserMiddleware', 

'cms.middleware.page.CurrentPageMiddleware', 

'cms.middleware.toolbar.ToolbarMiddleware', 

'cms.middleware.language.LanguageCookieMiddleware', 

 

'django.middleware.cache.FetchFromCacheMiddleware', 

) 

 

TEMPLATES = [ 

{ 

'BACKEND': 'django.template.backends.django.DjangoTemplates', 

'OPTIONS': { 

'loaders': [ 

('django.template.loaders.cached.Loader', ( 

'django.template.loaders.filesystem.Loader', 

'django.template.loaders.app_directories.Loader', 

)), 

], 

'context_processors': [ 

'django.contrib.auth.context_processors.auth', 

'django.contrib.messages.context_processors.messages', 

'django.template.context_processors.i18n', 

'django.template.context_processors.debug', 

'django.template.context_processors.request', 

'django.template.context_processors.media', 

'django.template.context_processors.csrf', 

'django.template.context_processors.tz', 

'sekizai.context_processors.sekizai', 

'django.template.context_processors.static', 

'cms.context_processors.cms_settings', 

'pylucid.context_processors.pylucid', 

], 

}, 

}, 

] 

 

 

# Database 

# https://docs.djangoproject.com/en/1.11/ref/settings/#databases 

 

# Must be set in page instance settings: 

DATABASES = {} 

 

 

# https://docs.djangoproject.com/en/1.11/topics/cache/#database-caching 

import sys 

if sys.argv[0].endswith("test") or "pytest" in sys.argv or "test" in sys.argv: 

print("Use 'LocMemCache' CACHES in tests, because of:") 

print("https://github.com/divio/django-cms/issues/5079") 

CACHES = { 

'default': { 

'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 

'LOCATION': 'unique-snowflake', 

} 

} 

else: 

# 

# The cache tables must be created first, e.g.: 

# $ manage.py createcachetable 

# 

CACHES = { 

'default': { 

'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 

'LOCATION': 'pylucid_cache_table', 

}, 

} 

 

# Hack needed, until https://github.com/divio/django-cms/issues/5079 is fixed: 

if "createcachetable" in sys.argv: 

INSTALLED_APPS = list(INSTALLED_APPS) 

INSTALLED_APPS.remove("cms") 

INSTALLED_APPS.remove("djangocms_blog") 

 

 

# https://django-compressor.readthedocs.io/en/latest/settings/ 

#COMPRESS_ENABLED=False 

COMPRESS_ENABLED=True 

 

 

STATICFILES_FINDERS = ( 

'django.contrib.staticfiles.finders.FileSystemFinder', 

'django.contrib.staticfiles.finders.AppDirectoriesFinder', 

# other finders.. 

'compressor.finders.CompressorFinder', 

) 

 

 

# Internationalization 

# https://docs.djangoproject.com/en/1.11/topics/i18n/ 

 

# Default and fallback language: 

# https://docs.djangoproject.com/en/1.11/ref/settings/#language-code 

LANGUAGE_CODE = "en" 

 

# http://docs.django-cms.org/en/latest/reference/configuration.html#std:setting-CMS_LANGUAGES 

CMS_LANGUAGES = { 

1: [ 

{ 

"name": _("English"), 

"code": "en", 

"fallbacks": ["de"], 

"redirect_on_fallback":True, 

"public": True, 

"hide_untranslated": False, 

}, 

{ 

"name": _("German"), 

"code": "de", 

"fallbacks": ["en"], 

"redirect_on_fallback":True, 

"public": True, 

"hide_untranslated": False, 

}, 

], 

"default": { # all SITE_ID"s 

"fallbacks": [LANGUAGE_CODE], 

"redirect_on_fallback":True, 

"public": True, 

"hide_untranslated": False, 

}, 

} 

 

# https://django-parler.readthedocs.io/en/latest/api/parler.utils.conf.html#parler.utils.conf.get_parler_languages_from_django_cms 

# PARLER_LANGUAGES will be generated from CMS_LANGUAGES since parler v1.6 

 

 

# https://docs.djangoproject.com/en/1.11/ref/settings/#languages 

# http://www.i18nguy.com/unicode/language-identifiers.html 

LANGUAGES = tuple([(d["code"], d["name"]) for d in CMS_LANGUAGES[1]]) 

 

LANGUAGE_DICT = dict(LANGUAGES) # useful to get translated name by language code 

 

# http://django-parler.readthedocs.org/en/latest/quickstart.html#configuration 

PARLER_DEFAULT_LANGUAGE_CODE = LANGUAGE_CODE 

 

 

TIME_ZONE = 'UTC' 

 

USE_I18N = True 

 

USE_L10N = True 

 

USE_TZ = True 

 

 

# Static files (CSS, JavaScript, Images) 

# https://docs.djangoproject.com/en/1.11/howto/static-files/ 

 

STATIC_URL = '/static/' 

MEDIA_URL = '/media/' 

 

# Must be set in settings from page instance: 

# STATIC_ROOT = 

# MEDIA_ROOT = 

 

 

# https://django-debug-toolbar.readthedocs.io/en/stable/configuration.html#debug-toolbar-config 

from debug_toolbar.settings import CONFIG_DEFAULTS as DEBUG_TOOLBAR_CONFIG 

 

# don't load jquery from ajax.googleapis.com, just use django's version: 

DEBUG_TOOLBAR_CONFIG["JQUERY_URL"] = STATIC_URL + "admin/js/vendor/jquery/jquery.min.js" 

 

 

# Basic Django CMS settings 

 

CMS_TEMPLATES = ( 

('pylucid/bootstrap/split_tree_menu_left.html', 'Split tree menu left'), 

('pylucid/bootstrap/fullwidth.html', 'Top menu - full width'), 

('pylucid/bootstrap/sidebar_left.html', 'Top menu with sidebar left'), 

('pylucid/bootstrap/homepage.html', 'Homepage template'), 

('pylucid/bootstrap/tree_menu_left.html', 'Tree menu left'), 

('pylucid/bootstrap/tree_menu_right.html', 'Tree menu right'), 

('pylucid/simple.html', 'Simple'), 

# ('base.html', 'Basic Page'), 

) 

 

# http://docs.django-cms.org/en/latest/reference/configuration.html#cms-permission 

CMS_PERMISSION = False 

 

# Basic Placeholder config 

 

# from djangocms_text_ckeditor.cms_plugins import TextPlugin 

CKEDITOR = "TextPlugin" 

 

from django_cms_tools.plugin_anchor_menu import constants as plugin_anchor_menu_constants 

 

CMS_PLACEHOLDER_CONF = { 

None: { 

'name': _("Content"), 

'plugins': [ 

CKEDITOR, 

plugin_anchor_menu_constants.ANCHOR_PLUGIN_NAME, 

plugin_anchor_menu_constants.DROP_DOWN_ANCHOR_MENU_PLUGIN_NAME, 

], 

'default_plugins': [ 

{ 

'plugin_type': CKEDITOR, 

'values':{'body':'<p>(There is no content, yet.)</p>'}, 

}, 

], 

}, 

} 

 

# https://djangocms-blog.readthedocs.io/en/latest/installation.html#minimal-configuration 

META_SITE_PROTOCOL = 'http' # Should be changed to "https" in production! 

META_USE_SITES = True 

 

 

# http://django-filer.readthedocs.org/en/latest/installation.html#configuration 

THUMBNAIL_PROCESSORS = ( 

'easy_thumbnails.processors.colorspace', 

'easy_thumbnails.processors.autocrop', 

'filer.thumbnail_processors.scale_and_crop_with_subject_location', 

'easy_thumbnails.processors.filters', 

) 

 

 

#_____________________________________________________________________________ 

# https://github.com/mitar/cmsplugin-markup 

CMS_MARKUP_OPTIONS = ( 

'cmsplugin_markup.plugins.creole', 

'cmsplugin_markup.plugins.html', 

'cmsplugin_markup.plugins.markdown', 

'cmsplugin_markup.plugins.textile', 

'cmsplugin_markup.plugins.restructuredtext', 

) 

CMS_MARKUP_RENDER_ALWAYS = True 

CMS_MARKDOWN_EXTENSIONS = () 

 

 

#_____________________________________________________________________________ 

# cut 'pathname' in log output 

 

import logging 

 

old_factory = logging.getLogRecordFactory() 

 

 

def cut_path(pathname, max_length): 

if len(pathname)<=max_length: 

return pathname 

return "...%s" % pathname[-(max_length-3):] 

 

 

def record_factory(*args, **kwargs): 

record = old_factory(*args, **kwargs) 

record.cut_path = cut_path(record.pathname, 30) 

return record 

 

 

logging.setLogRecordFactory(record_factory) 

 

 

# ----------------------------------------------------------------------------- 

 

 

# https://docs.python.org/3/library/logging.html#logging-levels 

LOGGING = { 

'version': 1, 

'disable_existing_loggers': True, 

'formatters': { 

'verbose': { 

'format': '%(levelname)8s %(cut_path)s:%(lineno)-3s %(message)s' 

}, 

}, 

'handlers': { 

'console': { 

'class': 'logging.StreamHandler', 

'formatter': 'verbose', 

} 

}, 

'loggers': { 

'': { 

'handlers': ['console'], 

'level': 'DEBUG', 

'propagate': False, 

}, 

'django': { 

'handlers': ['console'], 

'level': 'INFO', 

'propagate': False, 

}, 

'django_tools': { 

'handlers': ['console'], 

'level': 'DEBUG', 

'propagate': False, 

}, 

'django_cms_tools': { 

'handlers': ['console'], 

'level': 'DEBUG', 

'propagate': False, 

}, 

'pylucid': { 

'handlers': ['console'], 

'level': 'DEBUG', 

'propagate': False, 

}, 

}, 

}