TurboGears / tg2

Python web framework with full-stack layer implemented on top of a microframework core with support for SQL DBMS, MongoDB and Pluggable Applications
http://www.turbogears.org/
Other
806 stars 78 forks source link

Initial support to freeze turbogears. #62

Closed marcelotduarte closed 8 years ago

marcelotduarte commented 9 years ago

The zip library used by cx_freeze and py2exe does not support egg. The resource_filename is not supported in plain zip.

amol- commented 9 years ago

The idea looks good, but I'm not totally confident with the way the temporary directory is created. Maybe it should be better to rely on pkg_resources.get_default_cache(). Will it provide a reliable directory which we can avoid checking and creating ourselves?

Also as the temporary file path is created joining os.path.join(self.__temp_dir, basename) shouldn't it lead to collisions? If there are two packages with edit template they will end up overwriting one with the other. Instead of using the executable+basename wouldn't it be more reliable to use the full package path?

My two cents, but as we are messing with the user file system I want to ensure it's as reliable as possible :D

marcelotduarte commented 9 years ago

The change of tempfile.gettempdir() to get_default_cache() is identical, it will become a temporary directory as the same manner. Before, the extract files is in %temp%. With default_cache(), the directory is %appdata%\Python-Eggs, in my case. And, get_default_cache() does not create the directory and its subdirectories. In egg packages the directories will be created by resource_filename, but in zip, resource_filename is not supported/implemented.

About the collisions, I imagined a rare case, but...

A new request will be send.

marcelotduarte commented 9 years ago

I have a few questions to complete this task, which are closely related to how tg was made. Can I ask you a few things as problems arise? What is the best way? By email? The group?

So to advance. Making this change to the code, I managed to import the templates, except the "master.html". I had to use an ugly hack to continue testing. See the hack:

if getattr(sys, 'frozen', False):
    dotted_filename_finder = base_config['tg.app_globals']['dotted_filename_finder']
    dotted_filename_finder.get_dotted_filename(base_config.package_name+'.templates.master')