def create_static_file(sender, instance, signal, *args, **kwargs):
    if Page in sender.__bases__ or sender == Page:
        try:
            root_dir = settings.HTML_SITE_ROOT
        except AttributeError:
            root_dir  = settings.PROJECT_ROOT + "/" + "_site"
        try:
            if not os.path.exists(root_dir):
                os.makedirs(root_dir)
        except OSError, e :
            raise e
                    
        current_dir = root_dir
        os.chdir(current_dir)
        while instance:
            request = RequestMock().request()
            response = page(request, instance.slug)
            slug = instance.get_slug()
            slug_parts = slug.split('/')
            pos = 0
            length = len(slug_parts)
            filename = 'index.html'
            while(pos < length):
                current_dir = slug_parts[pos]
                if not os.path.exists(current_dir):
                    os.makedirs(current_dir)                
                os.chdir(current_dir)
                pos += 1
            fobj = open(filename, 'w')
            fobj.write(response.rendered_content)
            fobj.close()
            instance = instance.parent
            os.chdir(root_dir)
Esempio n. 2
0
File: urls.py Progetto: pconerly/pc
def home_page(request):
    request.path = "/"
    return page(request, "home")
Esempio n. 3
0
def home_page(request):
    # Links to: url("^$", "mezzanine.pages.views.page", {"slug": "/"}, name="home"),
    # Not needed. 
    request.path = "/" 
    return page(request, "home")
Esempio n. 4
0
def projects_list(*args, **kwargs):
    projects = Project.objects.all()

    return page(*args, extra_context={'projects': projects}, **kwargs)
Esempio n. 5
0
def homepage(request):
    request.path = "/"
    return page(request, slug="home")