[web2py] Re: Downloading from "private" folder

2010-06-23 Thread mdipierro
Two issues:

- you are donwloading from private not uploads folder. Thenically this
is ok but not a web2py convention. You should not expose the content
for the private folder. That is why it is called private. ;-)

- you used embed to embed a file, but it should be used to embed a
plugin. I have used a flash plugin for this purpose.

Here is an app to manage music files that you can use as example:

http://web2py.com/examples/static/web2py.app.music.w2p

Massimo

On Jun 22, 10:50 pm, weheh  wrote:
> Continuing this old 
> thread:http://groups.google.com/group/web2py/browse_thread/thread/59b66b3a24...
>
> I'm having trouble getting an embedded mp3 from showing up in my web
> page. I'm trying to implement this almost exactly as Massimo suggested
> in the above thread. Anybody know why my code below isn't functioning?
>
> #controller "audio.py"
> def download_audio():
>   f=os.path.join(request.folder,'private',request.args(0))
>   return response.stream(open(f,'rb'))
>
> #model "show_audio.py"
> def show_audio():
>   filename='audio/aab/hello_world.mp3'  # this is a hardcoded value
> for this test case
>   url=URL(r=request,c='audio',f='download_audio',args=filename)
>   return EMBED(_src=url,_autoplay='true')
>
> #view "index.html"
> {{=show_audio()}}


[web2py] Re: upload bug in filename

2010-06-23 Thread Swell
Ok
I will post some code here to show as much as possible

here is the db definition:

db.define_table('papers',
  Field('title','string'),
  Field('author','string'),
  Field('file','upload'),
  )

then if i try to use the database administration tool available in
Models section and try to insert a file like
"The Pricing of Options and Corporate Liabilities_Journal of Political
Economy.pdf" i then get a ticket complaining about

IOError: [Errno 2] No such file or directory:
C:\\Users\\M\\Desktop\\web2py_src\\web2py\\applications\\Library/
databases\\..\\uploads\
\papers.file.a33b16f5af29f6d8.5468652050726963696e67206f66204f7074696f6e7320616e6420436f72706f72617465204c696162696c69746965735f4a6f75726e616c206f6620506f6c69746963616c2045636f6e6f6d792e706466.pdf'

i also checked the file actually has never been properly uploaded ( it
is not present in the upload directory). Nothing special about size of
the file ( if i just  change manually the filename it works ). So it
seems that the bug is when we receiving the file .

hope we can sort this out
Thx all
M


[web2py] invite-friend slice

2010-06-23 Thread Rohan
Anybody aware of any plugin/slice available for inviting friends from
gmail, yahoo, hotmail, aol, facebook etc from a web application?

Thanks in advance.


[web2py] Hidden SQLFORM.factory Field

2010-06-23 Thread AsmanCom
Hi,

i can make a hidden Field by:

form = SQLFORM.factory(Field("field_name", type="hidden",
default="Off"))

Now the Form is hidden, but the Fieldname is still there, how can I
hide this?



THX


[web2py] Web2py and mobile browsing

2010-06-23 Thread Doug Warren
Does anyone have some hints for showing mobile browsers a different
set of views than desktop browsers?  IE: Detection, redirection,
etc...  Since the view is determined by the extension of the page how
do people handle it?


Re: [web2py] Re: Anvanced applications in gae

2010-06-23 Thread Carles
Sorry but, any thoughts?

Carles

El 22/06/2010, a las 19:56, Carles Gonzalez  escribió:

> My english is horrible, an maybe it wasn't clear, but that was exactly
> my problem :).
> 
> Currently i'm looking at the code massimo told me about but i think
> that the problem isn't here.
> 
> I explain: the parent is assigned when the child entity is created (at
> the constructor level), to ensure all entities on the same group are
> stored together (or close), that way transactions are feasible.
> 
> I don't think i'm capable of doing that right now, but my proposed
> soultion (just an idea) is to extend the field definition syntax for
> reference fields, adding an atribute to indicate this tipe of
> relationship.
> 
> Example (blatantly stolen from the book):
> 
> db.define_table('person',
>Field('name'))
> db.define_table('dog',
>Field('name'),
>Field('owner', db.person, relationship="parent"))
> 
> On SQL databases that attribute would be ignored, but in GAE web2py
> would enforce the parent relationship at creation and dog[id].parent
> would return the result of dog_instance.parent()
> 
> I don't know if this is feasible or if i'm total crazy (an option to
> consider). Opinions?
> 
> 
> On Tue, Jun 22, 2010 at 1:42 AM, Matt  wrote:
>> Any chance this could be considered as well?
>> 
>> Currently the DAL doesn't allow you to set the parent which is
>> required for GAE entity groups.
>> 
>> http://groups.google.com/group/web2py/browse_thread/thread/3c11deb2bfadf207/96a4324e5fd0cf71?lnk=gst&q=GAE+parent#96a4324e5fd0cf71
>> 
>> On Jun 22, 7:35 am, Carles  wrote:
>>> Ok, I'll try.
>>> 
>>> Carles
>>> 
>>> El 21/06/2010, a las 19:03, mdipierro  escribió:
>>> 
 The only file you need to look into is gluon/contrib/gql.py
>>> 
 specifically the select() function which calls filter returns the Rows
 object
>>> 
 On Jun 21, 11:55 am, Carles Gonzalez  wrote:
> Ok, thanks! I would like to make the patch myself, but the innards of
> web2py are somewhat complex...
>>> 
> Thanks again, Carles.
>>> 
> On Mon, Jun 21, 2010 at 6:43 PM, mdipierro  
> wrote:
>> Probably it would not be hard to implement. I will look into this next
>> week but if somebody sends me a patch before that I will take it.
>>> 
>> Massimo
>>> 
>> On Jun 21, 9:25 am, Carles Gonzalez  wrote:
>>> Hi,
>>> 
>>> I have developed some applications in web2py, and 2 are running
>>> currently in gae, but now i have serious problem.
>>> 
>>> My current project is a social application, and when i design
>>> (example) the tables to make an user follow the actions other user
>>> (twitter like) I find that many-to-many relationships in app-engine
>>> are not easily supported.
>>> 
>>> From my understanding using the tools present in web2py right i would
>>> need to do a lot of processing in memory, an that would hurt
>>> performance greatly.
>>> 
>>> The pattern proposed by app store developers uses lists and "parent"
>>> relationship:
>>> 
>>> class Message(db.Model):
>>> sender = db.StringProperty()
>>> body = db.TextProperty()
>>> 
>>> class MessageIndex(db.Model):
>>> receivers = db.StringListProperty()
>>> 
>>> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', 
>>> user_id)
>>> keys = [k.parent() for k in indexes)
>>> messages = db.get(keys)
>>> 
>>> For using that pattern in web2py I would need a method for specifying
>>> the parent of a model instance. Can I specify that relationship using
>>> any method I don't know? If not, would it be hard to implement?
>>> 
>>> Thanks in advance!


[web2py] OWASP Top Ten

2010-06-23 Thread Julius Minka
There is a new version here:
http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project

I wonder if it doesn't need to be reflected in the current version of
the Book or in web2py itself.
Julius



[web2py] Re: Hidden SQLFORM.factory Field

2010-06-23 Thread Yarko Tymciurak
On Jun 23, 8:23 am, AsmanCom  wrote:
> Hi,
>
> i can make a hidden Field by:
>
> form = SQLFORM.factory(Field("field_name", type="hidden",
> default="Off"))
>
> Now the Form is hidden, but the Fieldname is still there, how can I
> hide this?

If you don't want a field in form factory, simply don't define the
field;
If you don't want to include a field from an existing table,  before
SQLFORM or SQLFORM.factory set that field's
readable and writable attributes both to False.  (You can do this for
an SQLFORM.factory  Field too, if you're simply
doing things programatically, and just want to dynamically include the
field in a form).

Note: you can also make a memory database, and define a table in
memory

Hope this is helpful.

- Yarko
>
> THX


[web2py] Re: Anvanced applications in gae

2010-06-23 Thread Yarko Tymciurak

On Jun 23, 9:11 am, Carles  wrote:
> Sorry but, any thoughts?

Have you looked at http://www.web2py.com/book/default/section/6/6?search=puppy

or http://www.web2py.com/book/default/section/6/9?search=puppy  (you
could have a relationship field if you _needed_, or
you could simply have a parent / child table, with id of the parent in
a parent field, id of a child in child field)..

I'm not sure I know what you want / why you want this, why an
attribute on a field is "special" for your request

- Yarko

>
> Carles
>
> El 22/06/2010, a las 19:56, Carles Gonzalez  escribió:
>
>
>
> > My english is horrible, an maybe it wasn't clear, but that was exactly
> > my problem :).
>
> > Currently i'm looking at the code massimo told me about but i think
> > that the problem isn't here.
>
> > I explain: the parent is assigned when the child entity is created (at
> > the constructor level), to ensure all entities on the same group are
> > stored together (or close), that way transactions are feasible.
>
> > I don't think i'm capable of doing that right now, but my proposed
> > soultion (just an idea) is to extend the field definition syntax for
> > reference fields, adding an atribute to indicate this tipe of
> > relationship.
>
> > Example (blatantly stolen from the book):
>
> > db.define_table('person',
> >                    Field('name'))
> > db.define_table('dog',
> >                    Field('name'),
> >                    Field('owner', db.person, relationship="parent"))
>
> > On SQL databases that attribute would be ignored, but in GAE web2py
> > would enforce the parent relationship at creation and dog[id].parent
> > would return the result of dog_instance.parent()
>
> > I don't know if this is feasible or if i'm total crazy (an option to
> > consider). Opinions?
>
> > On Tue, Jun 22, 2010 at 1:42 AM, Matt  wrote:
> >> Any chance this could be considered as well?
>
> >> Currently the DAL doesn't allow you to set the parent which is
> >> required for GAE entity groups.
>
> >>http://groups.google.com/group/web2py/browse_thread/thread/3c11deb2bf...
>
> >> On Jun 22, 7:35 am, Carles  wrote:
> >>> Ok, I'll try.
>
> >>> Carles
>
> >>> El 21/06/2010, a las 19:03, mdipierro  escribió:
>
>  The only file you need to look into is gluon/contrib/gql.py
>
>  specifically the select() function which calls filter returns the Rows
>  object
>
>  On Jun 21, 11:55 am, Carles Gonzalez  wrote:
> > Ok, thanks! I would like to make the patch myself, but the innards of
> > web2py are somewhat complex...
>
> > Thanks again, Carles.
>
> > On Mon, Jun 21, 2010 at 6:43 PM, mdipierro  
> > wrote:
> >> Probably it would not be hard to implement. I will look into this next
> >> week but if somebody sends me a patch before that I will take it.
>
> >> Massimo
>
> >> On Jun 21, 9:25 am, Carles Gonzalez  wrote:
> >>> Hi,
>
> >>> I have developed some applications in web2py, and 2 are running
> >>> currently in gae, but now i have serious problem.
>
> >>> My current project is a social application, and when i design
> >>> (example) the tables to make an user follow the actions other user
> >>> (twitter like) I find that many-to-many relationships in app-engine
> >>> are not easily supported.
>
> >>> From my understanding using the tools present in web2py right i would
> >>> need to do a lot of processing in memory, an that would hurt
> >>> performance greatly.
>
> >>> The pattern proposed by app store developers uses lists and "parent"
> >>> relationship:
>
> >>> class Message(db.Model):
> >>>     sender = db.StringProperty()
> >>>     body = db.TextProperty()
>
> >>> class MessageIndex(db.Model):
> >>>     receivers = db.StringListProperty()
>
> >>> indexes = MessageIndex.all(keys_only = True).filter('receivers = ', 
> >>> user_id)
> >>> keys = [k.parent() for k in indexes)
> >>> messages = db.get(keys)
>
> >>> For using that pattern in web2py I would need a method for specifying
> >>> the parent of a model instance. Can I specify that relationship using
> >>> any method I don't know? If not, would it be hard to implement?
>
> >>> Thanks in advance!


[web2py] Re: Downloading from "private" folder

2010-06-23 Thread weheh
Massimo, thanks for the app. I'm studying it.

>From the doc, I'm not sure I get a crystal clear understanding of what
the web2py convention is.

Let's say my app lets you upload a music mp3 file, a file with a
description (liner notes), and a jpeg (album cover). These get
uploaded to "uploads". Should I allow them to be downloaded from
uploads or do I need to move them both to "static" first?

What if I mix the uploaded mp3 with some more music to make another
mp3 file, which isn't uploaded. Should it be moved to the static
folder?

Finally, the doc says, "private files are accessed by the controllers
but not directly by the
developer." I've been trying to parse that statement but it makes no
sense to me. I'm the developer. I write the controller. My controller
tries to access private directly. Does that make me not the developer?
So what exactly is the purpose of the private folder?

On Jun 23, 3:15 am, mdipierro  wrote:
> Two issues:
>
> - you are donwloading from private not uploads folder. Thenically this
> is ok but not a web2py convention. You should not expose the content
> for the private folder. That is why it is called private. ;-)
>
> - you used embed to embed a file, but it should be used to embed a
> plugin. I have used a flash plugin for this purpose.
>
> Here is an app to manage music files that you can use as example:
>
> http://web2py.com/examples/static/web2py.app.music.w2p
>
> Massimo
>
> On Jun 22, 10:50 pm, weheh  wrote:
>
> > Continuing this old 
> > thread:http://groups.google.com/group/web2py/browse_thread/thread/59b66b3a24...
>
> > I'm having trouble getting an embedded mp3 from showing up in my web
> > page. I'm trying to implement this almost exactly as Massimo suggested
> > in the above thread. Anybody know why my code below isn't functioning?
>
> > #controller "audio.py"
> > def download_audio():
> >   f=os.path.join(request.folder,'private',request.args(0))
> >   return response.stream(open(f,'rb'))
>
> > #model "show_audio.py"
> > def show_audio():
> >   filename='audio/aab/hello_world.mp3'  # this is a hardcoded value
> > for this test case
> >   url=URL(r=request,c='audio',f='download_audio',args=filename)
> >   return EMBED(_src=url,_autoplay='true')
>
> > #view "index.html"
> > {{=show_audio()}}


[web2py] Re: Concatenate str and int values in Model

2010-06-23 Thread greenpoise
just noticed the response, thanks. I guess is all about compute even
when it is strings and numeric fields..Thanks again

dan

On Jun 23, 2:51 am, mdipierro  wrote:
> db.vlanman.location.compute=lambda r: '%s%s' %
> (r['locationprevis'],r['patchnumber'])
>
> On Jun 22, 3:40 pm, greenpoise  wrote:
>
>
>
> > How could I concatenate two db field values in my Model?? My example
> > is this:
>
> > db.define_table('vlanman',
> >     Field('person',db.person,default=None),
> >     Field('switchselect'),
> >     Field('locationprefix'),
> >     Field('patchpanel'),
> >     Field('patchnumber'),
> >     Field('switchnumber'),
> >     Field('location'),
> >     Field('workstation'),
> >     Field('diagram','upload'))
>
> > I want location to be a combination of locationprefix (string) and
> > patchnumber (int)??
>
> > Thanks
> > dan


[web2py] Re: OWASP Top Ten

2010-06-23 Thread Joschua
I think it should be appended not updated, because that are just the
top security flaws, but all are important.

The new one are:
* A6: Security Misconfiguration (crucial)
* A9: Insufficient Transport Layer Protection
* A10: Unvalidated Redirects and Forwards

On Jun 23, 6:37 pm, Julius Minka  wrote:
> There is a new version 
> here:http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project
>
> I wonder if it doesn't need to be reflected in the current version of
> the Book or in web2py itself.
> Julius


[web2py] elFinder-web2py , Filemanager for Web2py!

2010-06-23 Thread Phyo Arkar
Finally after 2 days of hacking elfinder backend for Django from
http://www.elrte.ru/redmine/issues/128
, i have managed to get elFinder working (about 90% of features)

Attached is elFinder-web2py , still alot of improvement needed.

-Downloading files is not working yet but should be easy to fix.
-Help me make it more integrated into web2py
-Their method of DIrectory scanning is so slow , going to replace with
os.walk.

Please note that this is not for Production use.

I started a project , download and test there.

Note URL (Both in View and web2py_elcon) need to be change to your host:port
(i did with port 8080)

http://code.google.com/p/elfinder-web2py/downloads/list


[web2py] Re: Downloading from "private" folder

2010-06-23 Thread Russell
If you look at the ReportLab example in chapter 9 of the book, it uses
the private folder to make the PDF file, which is then deleted.  So I
guess that private is for temporary working stuff - a folder that can
be cleaned out if necessary.  And, if such a file is worth keeping, I
guess it should be moved to uploads?

On Jun 24, 5:13 am, weheh  wrote:
> Massimo, thanks for the app. I'm studying it.
>
> From the doc, I'm not sure I get a crystal clear understanding of what
> the web2py convention is.
>
> Let's say my app lets you upload a music mp3 file, a file with a
> description (liner notes), and a jpeg (album cover). These get
> uploaded to "uploads". Should I allow them to be downloaded from
> uploads or do I need to move them both to "static" first?
>
> What if I mix the uploaded mp3 with some more music to make another
> mp3 file, which isn't uploaded. Should it be moved to the static
> folder?
>
> Finally, the doc says, "private files are accessed by the controllers
> but not directly by the
> developer." I've been trying to parse that statement but it makes no
> sense to me. I'm the developer. I write the controller. My controller
> tries to access private directly. Does that make me not the developer?
> So what exactly is the purpose of the private folder?
>
> On Jun 23, 3:15 am, mdipierro  wrote:
>
> > Two issues:
>
> > - you are donwloading from private not uploads folder. Thenically this
> > is ok but not a web2py convention. You should not expose the content
> > for the private folder. That is why it is called private. ;-)
>
> > - you used embed to embed a file, but it should be used to embed a
> > plugin. I have used a flash plugin for this purpose.
>
> > Here is an app to manage music files that you can use as example:
>
> >http://web2py.com/examples/static/web2py.app.music.w2p
>
> > Massimo
>
> > On Jun 22, 10:50 pm, weheh  wrote:
>
> > > Continuing this old 
> > > thread:http://groups.google.com/group/web2py/browse_thread/thread/59b66b3a24...
>
> > > I'm having trouble getting an embedded mp3 from showing up in my web
> > > page. I'm trying to implement this almost exactly as Massimo suggested
> > > in the above thread. Anybody know why my code below isn't functioning?
>
> > > #controller "audio.py"
> > > def download_audio():
> > >   f=os.path.join(request.folder,'private',request.args(0))
> > >   return response.stream(open(f,'rb'))
>
> > > #model "show_audio.py"
> > > def show_audio():
> > >   filename='audio/aab/hello_world.mp3'  # this is a hardcoded value
> > > for this test case
> > >   url=URL(r=request,c='audio',f='download_audio',args=filename)
> > >   return EMBED(_src=url,_autoplay='true')
>
> > > #view "index.html"
> > > {{=show_audio()}}


[web2py] Re: dynamically growing form?

2010-06-23 Thread Russell
I would create a form with all 10 rows, hide all but the first 2 rows,
and then use jquery to progressively display the rest of the rows.
Add something like this to each of the rows...

form.element(_id=this_reference_id).append( A(' add', _href='#',
_onclick="jQuery('#%s').show()" % next_reference_id))



On Jun 23, 1:38 pm, Doug Warren  wrote:
> I started writing this a few times but I kept deleting it as I wasn't
> very clear so I'll try again.
>
> I'm looking to create a form that has some tabular data in it, 2
> columns, but the trick is that each submission of the form will have
> between 2-10 rows.  Each submission represents a single working set
> that can be edited later to have rows added/deleted.  And the rows
> have an order.  What I'm looking for basically is a table that starts
> out with 2 rows, 2 columns and a submit button, next to each row is a
> +/- button, if you hit the + button a new row will be added to the
> table below the row you hit the + on.  If you hit - the row you hit
> the - on would be removed from the form.  On submission all the rows
> would be added to the database and a crud form could be used to go
> back and edit the table again even deleting/adding rows.
>
> Is there any slice or best practice that will do this?  I was thinking
> something with JQuery tabular plugin but not sure how to handle the
> creation/deletion of rows part.


[web2py] web2py hosting in India

2010-06-23 Thread Narendran
Hi,
Do anyone know if any hosting solution in India supports web2py
deployments?

--
Thanks
Narendran


[web2py] Re: web2py hosting in India

2010-06-23 Thread vihang
You can use service like linode / slicehost /webfaction to deploy. If
you need managed deployment optimized for web2py with service in
India, contact me

Regards
Vihang

On Jun 24, 11:14 am, Narendran  wrote:
> Hi,
> Do anyone know if any hosting solution in India supports web2py
> deployments?
>
> --
> Thanks
> Narendran