diff --git a/__init__.py b/__init__.py
index 6d9197d..4ba383d 100644
--- a/__init__.py
+++ b/__init__.py
@@ -362,16 +362,33 @@ def selectLanguage( self, path ):
tmppath = [ urlparse.unquote( x ) for x in tmppath.lower().strip("/").split("/") ]
if len( tmppath )>0 and tmppath[0] in conf["viur.availableLanguages"]+list( conf["viur.languageAliasMap"].keys() ):
self.language = tmppath[0]
- return( path[ len( tmppath[0])+1: ] ) #Return the path stripped by its language segment
+ return path[ len( tmppath[0])+1: ] # Return the path stripped by its language segment
else: # This URL doesnt contain an language prefix, try to read it from session
- if session.current.getLanguage():
- self.language = session.current.getLanguage()
- elif "X-Appengine-Country" in self.request.headers.keys():
+ sessionLang = session.current.getLanguage()
+ if sessionLang:
+ self.language = sessionLang
+ return path
+ if "Accept-Language" in self.request.headers:
+ acceptLangHeader = self.request.headers["Accept-Language"]
+ if acceptLangHeader:
+ acceptLangHeader = acceptLangHeader.split(",")
+ # we only accept up to seven language entries here.
+ for possibleLang in acceptLangHeader[:7]:
+ lng = possibleLang.split("-")[0]
+ if lng in conf["viur.availableLanguages"] or lng in conf["viur.languageAliasMap"]:
+ self.language = lng
+ return path
+ elif ";" in lng:
+ lng = lng.split(";")[0]
+ if lng in conf["viur.availableLanguages"] or lng in conf["viur.languageAliasMap"]:
+ self.language = lng
+ return path
+ if "X-Appengine-Country" in self.request.headers.keys():
lng = self.request.headers["X-Appengine-Country"].lower()
if lng in conf["viur.availableLanguages"] or lng in conf["viur.languageAliasMap"]:
self.language = lng
- return( path )
-
+ return path
+ return path
def processRequest( self, path, *args, **kwargs ): #Bring up the enviroment for this request, handle errors
self.internalRequest = False
@@ -383,6 +400,22 @@ def processRequest( self, path, *args, **kwargs ): #Bring up the enviroment for
self.args = []
self.kwargs = {}
#Add CSP headers early (if any)
+
+ if conf["viur.earlyInterceptionHook"]:
+ try:
+ newPath = conf["viur.earlyInterceptionHook"](path)
+ if newPath != path:
+ self.response.clear()
+ self.response.set_status(410, "Gone")
+ self.response.out.write(newPath)
+ return
+ except errors.Redirect as err:
+ if conf["viur.debug.traceExceptions"]:
+ raise
+ logging.debug("early redirect: %r", err.url.encode("UTF-8"))
+ self.redirect(err.url.encode("UTF-8"))
+ return
+
if conf["viur.security.contentSecurityPolicy"] and conf["viur.security.contentSecurityPolicy"]["_headerCache"]:
for k,v in conf["viur.security.contentSecurityPolicy"]["_headerCache"].items():
self.response.headers[k] = v
diff --git a/bones/textBone.py b/bones/textBone.py
index 6bb006a..f84069f 100644
--- a/bones/textBone.py
+++ b/bones/textBone.py
@@ -48,7 +48,6 @@ def handle_data(self, data):
.replace(">", ">") \
.replace("\"", """) \
.replace("'", "'") \
- .replace("\n", "") \
.replace("\0", "")
if data.strip():
self.flushCache()
diff --git a/modules/cart.py b/modules/cart.py
index efbbf61..9538cd5 100644
--- a/modules/cart.py
+++ b/modules/cart.py
@@ -91,7 +91,8 @@ def view(self, *args, **kwargs):
items = SkelList( self.productSkel )
for skel in items:
- skel["amt"] = numericBone(
+ skel.clone()
+ skel.amt = numericBone(
descr="Quantity",
defaultValue=session.current["cart_products"][str(skel["key"].value)]["amount"])
diff --git a/modules/order.py b/modules/order.py
index d68e4a3..fa5116c 100644
--- a/modules/order.py
+++ b/modules/order.py
@@ -844,7 +844,7 @@ def archiveOrder(self, order):
self.sendOrderArchivedEMail( order.key.urlsafe() )
logging.error("Order archived: "+str( order.key.urlsafe() ) )
- @PeriodicTask(60*24)
+ # @PeriodicTask(60*24)
def startArchiveOrdersTask( self, *args, **kwargs ):
self.doArchiveActiveOrdersTask( (datetime.now()-self.archiveDelay).strftime("%d.%m.%Y %H:%M:%S"), None )
self.doArchiveCancelledOrdersTask( (datetime.now()-self.archiveDelay).strftime("%d.%m.%Y %H:%M:%S"), None )
diff --git a/tasks.py b/tasks.py
index 48646c8..e75cbb1 100644
--- a/tasks.py
+++ b/tasks.py
@@ -176,12 +176,14 @@ def index(self, *args, **kwargs):
continue
except db.EntityNotFoundError:
pass
+
res = self.findBoundTask( task )
+
if res: #Its bound, call it this way :)
- t, s = res
- t( s )
+ res[0]()
else:
task() #It seems it wasnt bound - call it as a static method
+
logging.debug("Successfully called task %s" % task.periodicTaskName )
if intervall:
# Update its last-call timestamp
diff --git a/template/editform_bone_select.html b/template/editform_bone_select.html
index 30b2b46..01d304f 100644
--- a/template/editform_bone_select.html
+++ b/template/editform_bone_select.html
@@ -28,14 +28,9 @@
>
{%- for key, descr in boneParams["values"].items() %}
{% if loop.first %}
-
+
{% endif %}
-
-
+
{% endfor -%}
{% endif %}