Mercurial > libervia-web
comparison libervia/server/pages.py @ 1157:64952ba7affe
pages: fixed children retrieval in onFileChange
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 23 Feb 2019 21:04:31 +0100 |
parents | 94f9d81a475e |
children | 6424d3684d1e |
comparison
equal
deleted
inserted
replaced
1156:3048bd137aaf | 1157:64952ba7affe |
---|---|
409 # we retrieve page by starting from site root and finding each path element | 409 # we retrieve page by starting from site root and finding each path element |
410 parent = page = site_root | 410 parent = page = site_root |
411 new_page = False | 411 new_page = False |
412 for idx, child_name in enumerate(path_elts): | 412 for idx, child_name in enumerate(path_elts): |
413 try: | 413 try: |
414 page = page.children[child_name] | 414 try: |
415 page = page.original.children[child_name] | |
416 except AttributeError: | |
417 page = page.children[child_name] | |
415 except KeyError: | 418 except KeyError: |
416 if idx != len(path_elts)-1: | 419 if idx != len(path_elts)-1: |
417 # a page has been created in a subdir when one or more | 420 # a page has been created in a subdir when one or more |
418 # page_meta.py are missing on the way | 421 # page_meta.py are missing on the way |
419 log.warning(_(u"Can't create a page at {path}, missing parents") | 422 log.warning(_(u"Can't create a page at {path}, missing parents") |
427 try: | 430 try: |
428 # we (re)create a page with the new/modified code | 431 # we (re)create a page with the new/modified code |
429 __, resource = cls.createPage(host, path, site_root, path_elts, | 432 __, resource = cls.createPage(host, path, site_root, path_elts, |
430 replace_on_conflict=True) | 433 replace_on_conflict=True) |
431 if not new_page: | 434 if not new_page: |
432 resource.children = page.original.children | 435 try: |
436 resource.children = page.original.children | |
437 except AttributeError: | |
438 # FIXME: this .original handling madness is due to EncodingResourceWrapper | |
439 # EncodingResourceWrapper should probably be removed | |
440 resource.children = page.children | |
433 except Exception as e: | 441 except Exception as e: |
434 log.warning(_(u"Can't create page: {reason}").format(reason=e)) | 442 log.warning(_(u"Can't create page: {reason}").format(reason=e)) |
435 else: | 443 else: |
436 url_elt = path_elts[-1] | 444 url_elt = path_elts[-1] |
437 if not new_page: | 445 if not new_page: |