[Sugar-devel] [PATCH Browse] Error page SL #3500

Samuel Greenfeld greenfeld at laptop.org
Tue Sep 18 13:34:02 EDT 2012


+DEFAULT_ERROR_PAGE = os.path.join(activity.get_bundle_path(),
+                                  'data/error_page.html')
{...}
+        f = open(DEFAULT_ERROR_PAGE, 'w')
+        f.write(html)
+        f.close()

activity.get_bundle_path() resolves to the directory the Activity is
installed in, which is not guaranteed to be writable.

For example: Fedora installs its Sugar activities as RPMs in subdirectories
of /usr/share/sugar/activities.  These directories are only
readable/writable by root.

Python can make a secure temporary file with the tempfile module, but be
aware that newer versions of Python will delete the file on close unless
you explicitly say not to.


And can we make this page able to retry both GET and POST requests?  We
might also have to preserve the HTTP Referrer header in order not to break
websites which check it.

In general I suspect this would be easier to handle within WebKit (if such
functionality is available) than by making a custom page external to
everything.


On Tue, Sep 18, 2012 at 1:00 PM, Manuel Kaufmann <humitos at gmail.com> wrote:

> On Tue, Sep 18, 2012 at 1:55 PM, Manuel Kaufmann <humitos at gmail.com>
> wrote:
> > This patch contains a HTML template (error_page.tmpl) that is used to
> > generate the error page with the correct language.
>
> Please, comments and suggestions are welcomed here. I didn't find an
> existent way (inside Sugar) to translate html content, so I decide to
> make it by myself.
>
> I created a file called "error_page.tmpl" that contains the html
> structure of the page with some placeholders to put the translated
> strings (those placeholders are substituted with the % operator) and a
> new html file is create: "error_page.html" with the correct strings
> and url to try again. Then, this file is used to tell WekKit to load
> that file as an uri:
>
>   self.load_uri('file://' + DEFAULT_ERROR_PAGE)
>
> That file is generated every time that the web page can't be reached
> for any reason.
>
> See you,
>
> --
> Kaufmann Manuel
> Blog: http://humitos.wordpress.com/
> Porfolio: http://fotos.mkaufmann.com.ar/
> PyAr: http://www.python.com.ar/
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120918/bc46b0d3/attachment.html>


More information about the Sugar-devel mailing list