Bläddra i källkod

[fix] Get Notification Deadlock

version-14
Anand Doshi 11 år sedan
förälder
incheckning
737a8dd5cb
6 ändrade filer med 39 tillägg och 12 borttagningar
  1. +12
    -2
      frappe/__init__.py
  2. +1
    -3
      frappe/app.py
  3. +24
    -5
      frappe/core/doctype/notification_count/notification_count.py
  4. Binär
      frappe/public/css/font/noto-sans.woff
  5. +1
    -1
      frappe/setup_logging.py
  6. +1
    -1
      frappe/utils/email_lib/email_body.py

+ 12
- 2
frappe/__init__.py Visa fil

@@ -7,8 +7,7 @@ globals attached to frappe module
from __future__ import unicode_literals from __future__ import unicode_literals


from werkzeug.local import Local, release_local from werkzeug.local import Local, release_local
import os, importlib, inspect
import json
import os, importlib, inspect, logging, json


# public # public
from frappe.__version__ import __version__ from frappe.__version__ import __version__
@@ -639,3 +638,14 @@ def get_print_format(doctype, name, print_format=None, style=None, as_pdf=False)
return html return html
else: else:
return html return html

logging_setup_complete = False
def get_logger(module=None):
from frappe.setup_logging import setup_logging
global logging_setup_complete

if not logging_setup_complete:
setup_logging()
logging_setup_complete = True

return logging.getLogger(module or "frappe")

+ 1
- 3
frappe/app.py Visa fil

@@ -20,15 +20,13 @@ import frappe.utils.response
import frappe.website.render import frappe.website.render
from frappe.utils import get_site_name from frappe.utils import get_site_name
from frappe.middlewares import StaticDataMiddleware from frappe.middlewares import StaticDataMiddleware
from frappe.setup_logging import setup_logging


local_manager = LocalManager([frappe.local]) local_manager = LocalManager([frappe.local])


_site = None _site = None
_sites_path = os.environ.get("SITES_PATH", ".") _sites_path = os.environ.get("SITES_PATH", ".")


setup_logging()
logger = logging.getLogger(__name__)
logger = frappe.get_logger()


@Request.application @Request.application
def application(request): def application(request):


+ 24
- 5
frappe/core/doctype/notification_count/notification_count.py Visa fil

@@ -5,8 +5,11 @@


from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
import MySQLdb
from frappe.model.document import Document from frappe.model.document import Document


logger = frappe.get_logger()

class NotificationCount(Document): class NotificationCount(Document):
pass pass


@@ -34,18 +37,34 @@ def get_notifications():
result = frappe.get_list(d, fields=["count(*)"], result = frappe.get_list(d, fields=["count(*)"],
filters=[[d, key, "=", condition[key]]], as_list=True)[0][0] filters=[[d, key, "=", condition[key]]], as_list=True)[0][0]


frappe.get_doc({"doctype":"Notification Count", "for_doctype":d,
"open_count":result}).insert(ignore_permissions=True)

open_count_doctype[d] = result open_count_doctype[d] = result


try:
frappe.get_doc({"doctype":"Notification Count", "for_doctype":d,
"open_count":result}).insert(ignore_permissions=True)

except MySQLdb.OperationalError, e:
if e.args[0] != 1213:
raise

logger.error("Deadlock")

for m in config.for_module: for m in config.for_module:
if m in notification_count: if m in notification_count:
open_count_module[m] = notification_count[m] open_count_module[m] = notification_count[m]
else: else:
open_count_module[m] = frappe.get_attr(config.for_module[m])() open_count_module[m] = frappe.get_attr(config.for_module[m])()
frappe.get_doc({"doctype":"Notification Count", "for_doctype":m,
"open_count":open_count_module[m]}).insert(ignore_permissions=True)

try:
frappe.get_doc({"doctype":"Notification Count", "for_doctype":m,
"open_count":open_count_module[m]}).insert(ignore_permissions=True)

except MySQLdb.OperationalError, e:
if e.args[0] != 1213:
raise

logger.error("Deadlock")



return { return {
"open_count_doctype": open_count_doctype, "open_count_doctype": open_count_doctype,


Binär
frappe/public/css/font/noto-sans.woff Visa fil


+ 1
- 1
frappe/setup_logging.py Visa fil

@@ -35,7 +35,7 @@ def setup_logging():
} }
}, },
"loggers": { "loggers": {
"frappe.app": {
"frappe": {
"level": "INFO", "level": "INFO",
"propagate": False, "propagate": False,
"filters": ["context_filter"], "filters": ["context_filter"],


+ 1
- 1
frappe/utils/email_lib/email_body.py Visa fil

@@ -31,7 +31,7 @@ class EMail:
Also provides a clean way to add binary `FileData` attachments Also provides a clean way to add binary `FileData` attachments
Also sets all messages as multipart/alternative for cleaner reading in text-only clients Also sets all messages as multipart/alternative for cleaner reading in text-only clients
""" """
def __init__(self, sender='', recipients=[], subject='', alternative=0, reply_to=None):
def __init__(self, sender='', recipients=(), subject='', alternative=0, reply_to=None):
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email import Charset from email import Charset
Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8') Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')


Laddar…
Avbryt
Spara