paths to files

3 views
Skip to first unread message

paulhide

unread,
Jan 11, 2010, 11:09:24 AM1/11/10
to geraldo-developers
If you use geraldo with django under a standard Linux/Apache/Mod-
python setup what are the default paths for files in the following two
situations:
1) an image file, e.g.
from geraldo import graphics
...
elements = [graphics.Image(..., filename='somegif.gif')
...
in what directory would you have to put somegif.gif so that geraldo
would find it.

2)generating multiple reports to a single file, when you use a
construction like

some_report_instance.generate_by(PDFGenerator, filename='somepdf.pdf',
return_canvas=True)

where will somepdf.pdf be written by default.

I have got both these to work by using absolute paths and giving
suitable permissions in the second case, but I cannot use absolute
paths in the production environment.


Paul Hide

Marinho Brandao

unread,
Jan 12, 2010, 4:18:18 AM1/12/10
to geraldo-d...@googlegroups.com
Hi Paul, good morning :)

well.. I have the habit to put on the first lines of settings.py file
the following code:

<code>
import os
PROJECT_ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
</code>

note that the absolute path is directory where 'settings.py' is in.
So, I use it on MEDIA_ROOT:

<code>
MEDIA_ROOT = os.path.join(PROJECT_ROOT_PATH, 'media')
</code>

so, I can use them everywhere I need on the code, for example on a
report image path, to upload files, etc.

:)

2010/1/11 paulhide <paul...@gmail.com>:

> --
> Você está recebendo esta mensagem porque se inscreveu no grupo "geraldo-developers" dos Grupos do Google.
> Para postar neste grupo, envie um e-mail para geraldo-d...@googlegroups.com.
> Para cancelar a inscrição nesse grupo, envie um e-mail para geraldo-develop...@googlegroups.com.
> Para obter mais opções, visite esse grupo em http://groups.google.com/group/geraldo-developers?hl=pt-BR.
>
>
>
>

--
Marinho Brandão (José Mário)
http://marinhobrandao.com/

paulhide

unread,
Jan 12, 2010, 5:39:00 AM1/12/10
to geraldo-users
Hi Marinho,

Yes, that's a very good idea and really more to do with python and
django than geraldo I suppose.

Muchisimas Obrigado

Paul Hide


On 12 Jan, 09:18, Marinho Brandao <mari...@gmail.com> wrote:
> Hi Paul, good morning :)
>
> well.. I have the habit to put on the first lines of settings.py file
> the following code:
>
> <code>
> import os
> PROJECT_ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
> </code>
>
> note that the absolute path is directory where 'settings.py' is in.
> So, I use it on MEDIA_ROOT:
>
> <code>
> MEDIA_ROOT = os.path.join(PROJECT_ROOT_PATH, 'media')
> </code>
>
> so, I can use them everywhere I need on the code, for example on a
> report image path, to upload files, etc.
>
> :)
>

> 2010/1/11 paulhide <paul.h...@gmail.com>:


>
>
>
> > If you use geraldo with django under a standard Linux/Apache/Mod-
> > python setup what are the default paths for files in the following two
> > situations:
> > 1) an image file, e.g.
> > from geraldo import graphics
> > ...
> > elements = [graphics.Image(..., filename='somegif.gif')
> > ...
> > in what directory would you have to put somegif.gif so that geraldo
> > would find it.
>
> > 2)generating multiple reports to a single file, when you use a
> > construction like
>
> > some_report_instance.generate_by(PDFGenerator, filename='somepdf.pdf',
> > return_canvas=True)
>
> > where will somepdf.pdf be written by default.
>
> > I have got both these to work by using absolute paths and giving
> > suitable permissions in the second case, but I cannot use absolute
> > paths in the production environment.
>
> > Paul Hide
>
> > --
> > Você está recebendo esta mensagem porque se inscreveu no grupo "geraldo-developers" dos Grupos do Google.
> > Para postar neste grupo, envie um e-mail para geraldo-d...@googlegroups.com.
> > Para cancelar a inscrição nesse grupo, envie um e-mail para geraldo-develop...@googlegroups.com.

> > Para obter mais opções, visite esse grupo emhttp://groups.google.com/group/geraldo-developers?hl=pt-BR.

Reply all
Reply to author
Forward
0 new messages