Looks like you are on Windows. Are you running this via the shell or the
command line? In that case, I think web2py uses the relative path for
request.folder. To get the absolute path, try:
os.path.abspath(os.path.join(request.folder, ...))
Anthony
On Thursday, July 9, 2015 at 8:46:52 AM UTC-4, reddyreddy wrote:
>
> I want to get the complete path If I do in this way Iam getting only from
> applications\appname....
>
> But inorder to give it to c compiler I need full path of the file like
> c:\web2py\.....etc
> Here is my db.py:
>
> import os
>
> db = DAL("sqlite://storage.sqlite")
>
> db.define_table('document',
> Field('title', unique=True),
> Field('file', 'upload',
> uploadfolder=os.path.join(request.folder,'static/temp')),
> Field('ori_file'),
> format = '%(title)s')
>
> db.define_table('config',
> Field('key', unique=True),
> Field('value'))
> db.document.title.requires = IS_NOT_IN_DB(db, db.document.title)
>
> *And here is my script that Iam trying to run.*
>
> import subprocess
> # retrieve upload path configuration value
> rows = db(db.config.key=='uploadpath').select(db.config.value)
> if rows:
> db.document.file.uploadfolder =
> os.path.join(request.folder,rows[0].value)
> documents = db().select(db.document.ALL)
> for document in documents:
> path = db.document.file.uploadfolder+'\\'+document.file
> print path
>
> Here path is giving value applications\... but I need it from C:\...
>
>
>
>
> On Wed, Jul 8, 2015 at 2:53 PM, Dave S <[email protected]> wrote:
>
>>
>>
>> On Wednesday, July 8, 2015 at 5:53:41 AM UTC-7, reddyreddy wrote:
>>>
>>> Iam not sure how to use it.
>>> I guess I was not clear in my earlier question.
>>> For the files that were uploaded, I want full path of the each. Because
>>> I want to give that path to the gcc so that my files get executed.
>>>
>>> Can you please explain me little more.
>>>
>>>
>>>
>>> On Tue, Jul 7, 2015 at 9:11 PM, Anthony <[email protected]> wrote:
>>>
>>>> os.path.join(request.folder, 'static', 'temp', filename)
>>>>
>>>>
>> os.path.join takes the components of a path (e.g., a "folder" and a
>> "file"), and makes a string that can be passed to routines like open().
>> You can also pass that string as an argument to subprocess() invocations,
>> or send it the user in a flash message (web2py sense).
>>
>> It is interesting that os.path.join() is cited several times on
>> <URL:http://docs.python.org/2/library/os.html>
>> but isn't described there ... because the docs have a separate page for
>> os.path:
>> <URL:http://docs.python.org/2/library/os.path.html#module-os.path>
>>
>> /dps
>>
>> Anthony's example takes request.folder, a couple of intermediate pieces
>> (subdirectories) and a filename.
>> The result is a string (or string-like type) that can be passed
>>
>>
>>> On Tuesday, July 7, 2015 at 5:40:39 PM UTC-4, reddyreddy wrote:
>>>>>
>>>>> Hello all,
>>>>>
>>>>> I want to get the full path of the files that were uploaded.
>>>>> Iam giving the uploaded folder as 'static/temp' in db.py.
>>>>>
>>>>> Thankyou in advance.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>> Resources:
>>>> - http://web2py.com
>>>> - http://web2py.com/book (Documentation)
>>>> - http://github.com/web2py/web2py (Source code)
>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "web2py-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> Chaitanya Pochampally
>>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Chaitanya Pochampally
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.