[web2py] looping through fields & updating

2011-07-10 Thread mart
Hi,

shouldn't something lik this work? or maybe i'm missing something for
passing in a variable for a field name?

id=db.local_user.insert(dateTime=datetime.now())
for key in localUserDict.keys():
for field in db.local_user.fields:
if field==key:
 
db(db.local_user.id==id).update(field=localUserDict[key])
db.commit()

the exception is of course that the Field field does not belong to the
local_user table

Thanks,
Mart :)


[web2py] Re: How to temporarily redirect all requests

2011-07-10 Thread Anthony
Are you saying you want to do this someplace other than in a model file? The 
model file will be the first place where you'll be able to introduce any 
application logic (prior to that it's just framework code getting executed).

On Sunday, July 10, 2011 3:48:47 PM UTC-4, Luis Goncalves wrote:

> more thoughts:
>
> could I do something like:
>
>- define a shared global variable  session.version 
> - = -1 initially, signifying no choice made
>- ? use a callback that gets executed *before *the controller that 
>responds to the request 
>   - if session.version >-1:
>let the responding controller do its thing
>   else:
>if controller allowed to run:
> let the controller run
>else:
> redirect to 'please choose version'
>   
> Is it possible to implement such a "callback"???
>
> (or is this not the right/best way to achieve the functionality I need?)
>
> thanks,
> Luis.
>


[web2py] Re: How to temporarily redirect all requests

2011-07-10 Thread pbreit
Also note that you can put anthony's code in a controller outside a function 
and it will run every time tha controller is called.


[web2py] Re: Helpers (general question and call for sticky)

2011-07-10 Thread pbreit
Pretty much the only helper I use in views is URL(). But I use helpers more 
extensively in controllers.


[web2py] Re: Helpers (general question and call for sticky)

2011-07-10 Thread Anthony
I think it's mostly a matter of personal preference, but some people prefer 
to use native HTML when it's in a view and the web2py helpers when it's in a 
controller (or model). The helpers are also useful any time you need to do 
any server side DOM parsing and manipulation (see 
http://www.web2py.com/book/default/chapter/05#Server-side-DOM-and-Parsing). 
Note, for building URLs, you should always use the URL() function (whether 
in a view or a controller).
 
Anthony

On Sunday, July 10, 2011 4:10:46 PM UTC-4, (m) wrote:

> Newbie to Web programmer here. Please be gentle. 
>
> I am trying to get my head around HTML helpers and see that they have 
> been discussed so much and so often in this group that (1) I can't 
> find what I'm looking for and (2) I am thinking there ought to be a 
> sticky someplace that talks about their proper care and feeding. 
>
> In particular, let's take the Image Blog example from The Book, file 
> default/index.html: 
>
> {{extend 'layout.html'}} 
> Current Images 
> {{=LI(A(image.title, _href=URL("show", args=image.id)))}} 
> {{for image in images:}} 
> {{=LI(A(image.title, _href=URL("show", args=image.id)))}} 
> {{pass}} 
>  
>
> My first approach to writing this would have been to use native HTML 
> as much as possible so as to make porting to or from templates as easy 
> as possible. Also helps (me) with readability. Something like: 
>
> {{extend 'layout.html'}} 
> Current Images 
>  
> {{for image in images:}} 
> {{=image.title}} li> 
> {{pass}} 
>  
>
> This approach seems to work -- but I am wondering if there is an 
> advantage to doing it with helpers that I am missing.



[web2py] Re: OffTopic Google+

2011-07-10 Thread pang
Do you think it will eventually become federated with a server we can
install like they did with google wave, or will it only run on their
servers?


[web2py] Re: How to temporarily redirect all requests

2011-07-10 Thread Luis Goncalves
Awesome!!! Thanks!!! I will try it out!!!
Luis.


[web2py] Helpers (general question and call for sticky)

2011-07-10 Thread (m)
Newbie to Web programmer here. Please be gentle.

I am trying to get my head around HTML helpers and see that they have
been discussed so much and so often in this group that (1) I can't
find what I'm looking for and (2) I am thinking there ought to be a
sticky someplace that talks about their proper care and feeding.

In particular, let's take the Image Blog example from The Book, file
default/index.html:

{{extend 'layout.html'}}
Current Images
{{=LI(A(image.title, _href=URL("show", args=image.id)))}}
{{for image in images:}}
{{=LI(A(image.title, _href=URL("show", args=image.id)))}}
{{pass}}


My first approach to writing this would have been to use native HTML
as much as possible so as to make porting to or from templates as easy
as possible. Also helps (me) with readability. Something like:

{{extend 'layout.html'}}
Current Images

{{for image in images:}}
{{=image.title}}
{{pass}}


This approach seems to work -- but I am wondering if there is an
advantage to doing it with helpers that I am missing.


Re: [web2py] Re: How to temporarily redirect all requests

2011-07-10 Thread Jonathan Lundell
On Jul 10, 2011, at 12:48 PM, Luis Goncalves wrote:
> more thoughts:
> 
> could I do something like:
> define a shared global variable  session.version 
> = -1 initially, signifying no choice made
> ? use a callback that gets executed before the controller that responds to 
> the request
> if session.version >-1:
>  let the responding controller do its thing
> else:
>  if controller allowed to run:
>   let the controller run
>  else:
>   redirect to 'please choose version'
> Is it possible to implement such a "callback"???
> 
> (or is this not the right/best way to achieve the functionality I need?)

Anthony's idea of doing it in a model sounds good.

Or you could write a decorator, along the lines of @auth.requires_login(), that 
performed the tests you need.



[web2py] Re: How to temporarily redirect all requests

2011-07-10 Thread Luis Goncalves
more thoughts:

could I do something like:

   - define a shared global variable  session.version 
   - = -1 initially, signifying no choice made
   - ? use a callback that gets executed *before *the controller that 
   responds to the request
  - if session.version >-1:
   let the responding controller do its thing
  else:
   if controller allowed to run:
let the controller run
   else:
redirect to 'please choose version'
  
Is it possible to implement such a "callback"???

(or is this not the right/best way to achieve the functionality I need?)

thanks,
Luis.


[web2py] Re: How to temporarily redirect all requests

2011-07-10 Thread Anthony
You could do the check in a model file -- all (non-conditional) model files 
are executed on every request (before the requested controller action). 
E.g.:
 
if not (session.version_selected or 
request.function=='version_selection_page'):
redirect(URL('default','version_selection_page')
 
 
Anthony

On Sunday, July 10, 2011 3:22:44 PM UTC-4, Luis Goncalves wrote:

> Hello Everyone!
>
> Is there a simple/efficient/secure way to temporarily redirect all requests 
> to a specific page?
> (all requests except for those that define a few actions that are permitted 
> at that point in time)
>
> The context:
>
>- When user logs in, he needs to choose the version of the website to 
>use (different version access different sets of data) 
>- Until he chooses a version, clicking on any of the menu options, or 
>links, or typing in any URL should not execute normally, but rather send 
> him 
>(keep him on) a page that tells him to "please select a version" 
>- Ideally, selecting the version is done from the 'version' menubar 
>option, so these still have to work properly.
>
> An ugly way to do this is to have every single possible action 
> (URL,controller) check if the version selection has been done or not,  but 
> that seems like an inelegant, brute-force approach (and prone to errors if 
> new functionality is added whilst forgetting to include the check).
>
> Thanks!!!
>
> Luis.
>


[web2py] Re: login problem

2011-07-10 Thread Anthony
Hmm, I tried the code you provided below (with ajax=True as well as with 
ajax=False/ajax_trap=True), and it worked fine for me (though I did have to 
set auth.settings.login_next=URL('default','login2') -- otherwise, the 
component redirects to the index page, which displays the entire index page 
in the component div). Note, I don't think request.vars will show anything, 
because when you submit the login, it ends up redirecting, which generates a 
new request with empty request.vars.
 
Anthony

On Saturday, July 9, 2011 11:52:57 AM UTC-4, LightOfMooN wrote:

> ajax=True doesn't work too 
>
> I make it clear: 
> layout.html 
> {{=LOAD('default','login2',vars=request.vars, ajax=True)}} 
>
> default/login.html: 
>  
> {{=BEAUTIFY(request.vars)}} 
> {{if not auth.user:}} 
> {{=form}} 
> {{else:}} 
> logout 
> {{pass}} 
>  
>
> default.py: 
> def login2(): 
> form=auth.login() 
> return dict(form=form) 
>
> And it doesn't work with LOAD()(doesn't matter ajax=False/True, 
> ajax_trap=False/True, I tried all) 
> Even if I click on submit, there are no vars from form.hidden_fields() 
> displayed. 
>
> On 9 июл, 20:47, Anthony  wrote: 
> > Not sure what the problem is. Is your login view login.html or 
> login.load? 
> > If the latter, your LOAD call should include 'login.load' (otherwise it 
> will 
> > default to 'load.html'). 
> > 
> > You might also consider using the form.custom elements to build your form 
>
> > rather than doing everything manually, as described here:
> http://web2py.com/book/default/chapter/07#Custom-forms. For example, 
> > form.custom.end will do the same thing as form.hidden_fields(), but will 
> > also add the closing  tag. 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Saturday, July 9, 2011 9:52:17 AM UTC-4, LightOfMooN wrote: 
> > > So, I changed LOAD to {{=LOAD('default','login', vars=request.vars, 
> > > ajax_trap=True, ajax=False)[0][0]}} 
> > > but it stays not to log in. 
> > > I add {{=BEAUTIFY(request.vars)}} in the default/login.html 
> > > When I click on submit, I see, that vars contains just password, 
> > > remember and username. 
> > > There are no vars from {{=form.hidden_fields()}} 
> > 
> > > On 9 июл, 19:29, Anthony  wrote: 
> > > > Try adding ajax_trap=True to your LOAD call. Without that, your form 
> will 
> > > be 
> > > > posted to the action of the parent page, which is not prepared to 
> process 
> > 
> > > > the login submission. ajax_trap=True will post the form submission 
> back 
> > > to 
> > > > the login() action. Or you can just use ajax=True for the login 
> > > component. 
> > 
> > > > Anthony 
> > 
> > > > On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote: 
> > > > > Hello. 
> > > > > I'm trying to make a login viewlet. 
> > 
> > > > > So, I have function in controller "default": 
> > > > > def login(): 
> > > > > return dict(form=auth.login()) 
> > 
> > > > > And view: 
> > > > >  
> > > > > {{if not auth.user:}} 
> > > > >  
> > > > >  
> > > > > Login 
> > > > >  
> > > > >  
> > > > > Password 
> > > > >  
> > > > >  
> > > > >  > > > > checked="checked">remember me 
> > > > >  
> > > > > {{=form.hidden_fields()}} 
> > > > >  
> > > > >  
> > > > >  
> > > > >  
> > > > > {{else:}} 
> > > > > logout 
> > > > > {{pass}} 
> > > > >  
> > 
> > > > > By url /default/login it works fine, but when I include it in 
> > > > > layout.html with 
> > > > > {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}} 
> > > > > it doesn't log user in. 
> > 
> > > > > How to make it works? thx



[web2py] How to temporarily redirect all requests

2011-07-10 Thread Luis Goncalves
Hello Everyone!

Is there a simple/efficient/secure way to temporarily redirect all requests 
to a specific page?
(all requests except for those that define a few actions that are permitted 
at that point in time)

The context:

   - When user logs in, he needs to choose the version of the website to use 
   (different version access different sets of data)
   - Until he chooses a version, clicking on any of the menu options, or 
   links, or typing in any URL should not execute normally, but rather send him 
   (keep him on) a page that tells him to "please select a version"
   - Ideally, selecting the version is done from the 'version' menubar 
   option, so these still have to work properly.

An ugly way to do this is to have every single possible action 
(URL,controller) check if the version selection has been done or not,  but 
that seems like an inelegant, brute-force approach (and prone to errors if 
new functionality is added whilst forgetting to include the check).

Thanks!!!

Luis.


[web2py] Re: auth with OpenID - auth.environment.URL(...) error

2011-07-10 Thread Anthony
No problem. Glad it worked. Thanks for submitting the patch.
 
Anthony

On Sunday, July 10, 2011 1:26:06 PM UTC-4, Brian M wrote:

> Bingo - I'll start an issue over in google code & submit the patch.  Thanks 
> Anthony!



Re: [web2py] Re: Linking directly to an uploaded image

2011-07-10 Thread pbreit
Does the download() function handle the file paths properly?

def download():
"""
allows downloading of uploaded files
http:///[app]/default/download/[filename]
"""
return response.download(request,db)



[web2py] Re: Google app engine and DAL

2011-07-10 Thread Shark
Thanks howesc for your help

On Jul 10, 6:36 pm, howesc  wrote:
> Shark,
>
> the upload field will work (though you might have to pass the flag to tell
> it to store the file in the DB).  it's been a while since i have used that
> on GAE.
>
> if your uploaded file will be larger than 1MB (the current limit for blob
> fields assuming the online docs here are 
> correcthttp://code.google.com/appengine/docs/python/datastore/datamodeling.h...),
> then you can try storing in the 
> blobstore:http://www.web2pyslices.com/slices/take_slice/63


[web2py] Re: Web Shell problem on Mozilla Firefox 5 and Internet Explorer 9 (PC with Vista)

2011-07-10 Thread Anthony
I think the web shell can be a little quirky, especially in IE on Windows. I 
usually just use the Windows shell. To make it easy to quickly run a 
particular app (and optionally run a specific controller), I have put a 
'web2py shell.bat' file on my desktop with the following content:
 
@echo off
set /P app="Enter app/controller to run (controller optional): "
cd c:\path\to\web2py
python web2py.py -S %app% -M -N
 
Just double click on the batch file and it will open a command window and 
prompt for an app name (you can optionally add a controller to run within 
the app). If you don't like the default size and color of the Windows 
command window, once it's open, click the icon in the upper left, and select 
"Defaults" in the menu -- you can change the default window size and 
position, font, colors, etc.
 
Anthony

On Sunday, July 10, 2011 1:08:43 PM UTC-4, Valter Foresto wrote:

> I noted alternate functioning of Web Shell on Mozilla Firefox 5 and 
> Internet Explorer 9 on a PC with Vista installed OS.
> I currently use the last Version 1.97.1 (2011-06-26 19:25:44) of web2py.
>
> Anyone noted the same problem ?
> - Valter
>


Re: [web2py] Re: admin complains at encoder

2011-07-10 Thread Carl Roach
cheers. I'll look into it.



On 10 Jul 2011, at 17:30, howesc  wrote:

> looks to me like admin is posting data as a string, not something with a 
> timetuple() method.  don't all form posts come to you as strings and would 
> need to be cast to other types before storing in the DB?


[web2py] Re: auth with OpenID - auth.environment.URL(...) error

2011-07-10 Thread Brian M
Bingo - I'll start an issue over in google code & submit the patch.  Thanks 
Anthony!

[web2py] Web Shell problem on Mozilla Firefox 5 and Internet Explorer 9 (PC with Vista)

2011-07-10 Thread Valter Foresto
I noted alternate functioning of Web Shell on Mozilla Firefox 5 and Internet 
Explorer 9 on a PC with Vista installed OS.
I currently use the last Version 1.97.1 (2011-06-26 19:25:44) of web2py.

Anyone noted the same problem ?
- Valter


[web2py] Re: Google app engine and DAL

2011-07-10 Thread howesc
Shark,

the upload field will work (though you might have to pass the flag to tell 
it to store the file in the DB).  it's been a while since i have used that 
on GAE.

if your uploaded file will be larger than 1MB (the current limit for blob 
fields assuming the online docs here are correct 
http://code.google.com/appengine/docs/python/datastore/datamodeling.html#Property_Classes_and_Types),
 
then you can try storing in the blobstore: 
http://www.web2pyslices.com/slices/take_slice/63




[web2py] Re: admin complains at encoder

2011-07-10 Thread howesc
looks to me like admin is posting data as a string, not something with a 
timetuple() method.  don't all form posts come to you as strings and would 
need to be cast to other types before storing in the DB?


[web2py] Re: Google app engine and DAL

2011-07-10 Thread Shark
Thanks massimo for reply
but my question
will upload field work in GAE and will save the data in datastore or I
have to define field as anther type ?

example
b.define_table('person',
Field('image', 'upload'))


As it by default save data in upload folder


thanks in advance
On Jul 10, 5:18 pm, Massimo Di Pierro 
wrote:
> In web2py a Field(...,'upload') makes both a StringProperty and a
> BlobProperty. The filename goes in one and the data in the other.
> I think BlobProperty has a 10MB limitation but I am not sure. These
> numbers change as GAE evolves.
>
> Massimo
>
> On Jul 10, 8:22 am, Shark  wrote:
>
>
>
>
>
>
>
> > We want to save a blob to datastore in GAE
> > not only save the name
> > is this the same as upload field
>
> > On Jul 9, 9:51 pm, Shark  wrote:
>
> > > Ok thank very much Anthony
>
> > > On Jul 9, 4:32 pm, Anthony  wrote:> On Saturday, 
> > > July 9, 2011 8:07:48 AM UTC-4, Shark wrote:
>
> > > > > I need help in updating list field can anyone give example of how to
> > > > > update list field ?
>
> > > > > also I have problem in uploading files in GAE as web2py store them in
> > > > > files and google app engine need to store them in big table
>
> > > > web2py is supposed to store uploaded files in the datastore -- are you
> > > > saying that's not happening? 
> > > > Seehttp://web2py.com/book/default/chapter/11#Avoid-the-Filesystem.
>
> > > > Anthony


[web2py] Re: Google app engine and DAL

2011-07-10 Thread Massimo Di Pierro
In web2py a Field(...,'upload') makes both a StringProperty and a
BlobProperty. The filename goes in one and the data in the other.
I think BlobProperty has a 10MB limitation but I am not sure. These
numbers change as GAE evolves.

Massimo

On Jul 10, 8:22 am, Shark  wrote:
> We want to save a blob to datastore in GAE
> not only save the name
> is this the same as upload field
>
> On Jul 9, 9:51 pm, Shark  wrote:
>
>
>
>
>
>
>
> > Ok thank very much Anthony
>
> > On Jul 9, 4:32 pm, Anthony  wrote:> On Saturday, July 
> > 9, 2011 8:07:48 AM UTC-4, Shark wrote:
>
> > > > I need help in updating list field can anyone give example of how to
> > > > update list field ?
>
> > > > also I have problem in uploading files in GAE as web2py store them in
> > > > files and google app engine need to store them in big table
>
> > > web2py is supposed to store uploaded files in the datastore -- are you
> > > saying that's not happening? 
> > > Seehttp://web2py.com/book/default/chapter/11#Avoid-the-Filesystem.
>
> > > Anthony


[web2py] Re: Google app engine and DAL

2011-07-10 Thread Shark
We want to save a blob to datastore in GAE
not only save the name
is this the same as upload field

On Jul 9, 9:51 pm, Shark  wrote:
> Ok thank very much Anthony
>
> On Jul 9, 4:32 pm, Anthony  wrote:> On Saturday, July 9, 
> 2011 8:07:48 AM UTC-4, Shark wrote:
>
> > > I need help in updating list field can anyone give example of how to
> > > update list field ?
>
> > > also I have problem in uploading files in GAE as web2py store them in
> > > files and google app engine need to store them in big table
>
> > web2py is supposed to store uploaded files in the datastore -- are you
> > saying that's not happening? 
> > Seehttp://web2py.com/book/default/chapter/11#Avoid-the-Filesystem.
>
> > Anthony


Re: [web2py] Re: Call functions periodically from WEB2PY at short time basis (like 0.05 ... 5 seconds)

2011-07-10 Thread Roberto De Ioris

Il giorno 08/lug/2011, alle ore 18.14, Francisco Costa ha scritto:

>> Hardo to say. 0.9.7 branch is now obsolete, and a lot of fix has been
>> added to signal framework in 0.9.8. If you want to manage timer reliably
>> you should use the latest tip (it is really the 0.9.8.2 release, i am only
>> waiting for a last patch before release)
>> 
>> --
>> Roberto De Iorishttp://unbit.it
> 
> I now have installed uwsgi-0.9.8.1 from source
> 
> How do you install uwsgi decorators in Ubuntu 11.04
> 
> I found that there is a python-uwsgidecorators package but its only
> available for Ubuntu 11.10


You can download the file from here

http://projects.unbit.it/uwsgi/browser/uwsgidecorators.py

and put it in the web2py directory (or whatever dir you have in the pythonpath)

--
Roberto De Ioris
http://unbit.it



Re: [web2py] Re: Linking directly to an uploaded image

2011-07-10 Thread Ivica Kralj
Actually,

I just found solution for my app, again if somebody can provide more
portable solution that would be great?



   


Cheers
Ivica


On 10 July 2011 00:31, IK  wrote:

> Hi Massimo,
>
> When "uploadseparate" is set to True, previously mentioned solution
> will not work, at least not for me.
>
> Although, Bruno gave us one suggestion, I would prefer to use explicit
> image location rather than image ID.
>
> To explain:
>
> ###model:
>
> db.define_table("image",
> ...
>
> Field('file',"upload",uploadseparate=True,required=True,uploadfolder=request.folder
> +'static/' ),
> ...
>
>
> ###view
>
>{{url = URL('static',image.file)}}
> {{=A(IMG(_src=url), _href=url)}}
>
>
> This would give invalid file location:
> "
>
> "
> while correct url is
>127.0.0.1/app/static/image.file/91/image.file.
> 9197cf1918d6a0fa.6b617374656c61352e6a7067.jpg
>
>
> In attempt to find a solution, I was playing with SUBSTR, but I'm not
> getting clean output (I'm not sure if this is good approach, specially
> from portability point of view)
>
>
> ###contr
> ...
> img_folder= dbselect(db.image.file [11:13])
> return dict(img_folder=img_folder)
>
> ###view
> {{=img_folder}}
>
>
>
> and output is
> "
> SUBSTR(image.file,12,(14 - 12))
> 91
> "
>
> If you could give me some pointers, that would be greatly appreciated.
>
> Thanks
> IK
>
> On Jun 17, 3:18 pm, Massimo Di Pierro 
> wrote:
> > This is fine:
> >
> > db.define_table('announce',
> > Field('picture','upload',uploadfolder=request.folder+'static/
> > pictures'),
> > )
> >
> > but why do you need an action to download from the static folder? Why
> > not simply use
> >
> > URL('static',record.picture)
> >
> > On Jun 17, 5:56 am, Bruno Rocha  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > For security reasons, web2py does not expose the 'uploads' folder to
> the
> > > user, this folder can be accessed only by the 'download' function.
> >
> > > The best way is to set the upload path pointing to /static not to
> /upload
> > > and you will have youruploadedfiles to be served as static files,
> > > bypassing download function.
> >
> > > under /static create a folder called 'picture'
> >
> > > *Go to the table definition and do this:*
> >
> > > **
> > > db.define_table('announce',
> >
> > >
> Field('picture','upload',uploadfolder=request.folder+'static/pictures'),
> > > )
> > > **
> >
> > > You are saying DAL to store uploades files in to that folder under
> static
> > > and store the ath in the field.
> >
> > > Now in your controller create a function do handle that (different from
> > > download, it is a kind of viewer)
> >
> > > **
> > > def viewer():
> > > row = db(db.announce.id
> > > ==request.args(0)).select(db.announce.picture).first()
> > > redirect(URL('static','pictures',args=row.picture))
> > > **
> >
> > > *Now you can fo this:*
> >
> > >http://server/app/default/viewer/3#record id
> >
> > > then you got redirected to theimage(no html page)
> >
> > > example:
> http://127.0.0.1:8000/app/static/pictures/announce.picture.aaf5d3f777...
> >
> > > you can always referdirectlyto theimagepath (not using the viewer
> > > function) but you always need to fetch the picture name from db.
> >
> > > Hope it helps.
> >
> > > Should go on the book?
> >
> > > --
> > > Bruno Rocha
> > > [ About me:http://zerp.ly/rochacbruno]
> > > [ Aprenda a programar:http://CursoDePython.com.br]
> >
> > > On Thu, Jun 16, 2011 at 6:09 AM, Vinicius Assef  >wrote:
> >
> > > > Hi guys.
> >
> > > > I have a table (called anuncio) with an upload field (called foto),
> so
> > > > anuncio.foto is my upload field.
> >
> > > > I'm showing andlinkingit with this piece of code in my view :
> > > >{{url = URL(c='anuncios',f='download', args=['uploads',
> anuncio.foto])}}
> > > >{{=A(IMG(_src=url), _href=url)}}
> >
> > > > My 
> > > > /contollers/anuncios.py/download()function
> > > >  is the default, as seen
> > > > below:
> > > > def download():
> > > >return response.download(request,db)
> >
> > > > When user clicks on thisimage, browser shows the download dialog,
> > > > asking him/her where to save theimage.
> > > > But I'd like to simply show theimage, not present the download
> > > > dialog. All these images will be public.
> >
> > > > How I solved it:
> > > > 1) I entered in /myapp/static/images and created a symbolic link
> > > > called 'uploads' pointing to /myapp/uploads.
> > > > 2) In my view, I changed the: {{url = URL(...}} stuff by this: {{url
> =
> > > > URL(c='static', f='images', args=['uploads', anuncio.foto])}}
> >
> > > > I think this isn't the best choice because I'm pointing URL() to a
> > > > fake controller and function, and I'm counting on an external
> > > > resource: a symbolic link in my filesystem.
> >
> > > > How would be the "web2pythonic" way to do this?
> >
> > > > --
> > > > Vinicius Assef.
>


[web2py] mapreduce.appspot.com

2011-07-10 Thread hcvst
Hi,

I'm thinking of using this mapreduce lib for GAE, however it expects one to 
reference GAE entity_kinds. Is there a way to reference the underlying GAE 
entity through DAL?
I've run into this problem in the past when trying to apply some GAE 
specific functions such as cursors for paging.

Woud you recommend to use GAE types rather than DAL from the outset, if of 
one knows that one will only need to run on GAE?

 Regards,
HC


[web2py] Re: login problem

2011-07-10 Thread LightOfMooN
Also nothing happens

On 10 июл, 02:42, Anthony  wrote:
> What happens if you remove vars=request.vars from LOAD()?
>
> On Jul 9, 11:52 am, LightOfMooN  wrote:
>
>
>
>
>
>
>
> > ajax=True doesn't work too
>
> > I make it clear:
> > layout.html
> > {{=LOAD('default','login2',vars=request.vars, ajax=True)}}
>
> > default/login.html:
> > 
> > {{=BEAUTIFY(request.vars)}}
> > {{if not auth.user:}}
> >     {{=form}}
> > {{else:}}
> >     logout
> > {{pass}}
> > 
>
> > default.py:
> > def login2():
> >     form=auth.login()
> >     return dict(form=form)
>
> > And it doesn't work with LOAD()    (doesn't matter ajax=False/True,
> > ajax_trap=False/True, I tried all)
> > Even if I click on submit, there are no vars from form.hidden_fields()
> > displayed.
>
> > On 9 июл, 20:47, Anthony  wrote:
>
> > > Not sure what the problem is. Is your login view login.html or login.load?
> > > If the latter, your LOAD call should include 'login.load' (otherwise it 
> > > will
> > > default to 'load.html').
>
> > > You might also consider using the form.custom elements to build your form
> > > rather than doing everything manually, as described 
> > > here:http://web2py.com/book/default/chapter/07#Custom-forms. For example,
> > > form.custom.end will do the same thing as form.hidden_fields(), but will
> > > also add the closing  tag.
>
> > > Anthony
>
> > > On Saturday, July 9, 2011 9:52:17 AM UTC-4, LightOfMooN wrote:
> > > > So, I changed LOAD to {{=LOAD('default','login', vars=request.vars,
> > > > ajax_trap=True, ajax=False)[0][0]}}
> > > > but it stays not to log in.
> > > > I add {{=BEAUTIFY(request.vars)}} in the default/login.html
> > > > When I click on submit, I see, that vars contains just password,
> > > > remember and username.
> > > > There are no vars from {{=form.hidden_fields()}}
>
> > > > On 9 июл, 19:29, Anthony  wrote:
> > > > > Try adding ajax_trap=True to your LOAD call. Without that, your form 
> > > > > will
> > > > be
> > > > > posted to the action of the parent page, which is not prepared to 
> > > > > process
>
> > > > > the login submission. ajax_trap=True will post the form submission 
> > > > > back
> > > > to
> > > > > the login() action. Or you can just use ajax=True for the login
> > > > component.
>
> > > > > Anthony
>
> > > > > On Saturday, July 9, 2011 9:06:17 AM UTC-4, LightOfMooN wrote:
> > > > > > Hello.
> > > > > > I'm trying to make a login viewlet.
>
> > > > > > So, I have function in controller "default":
> > > > > > def login():
> > > > > >     return dict(form=auth.login())
>
> > > > > > And view:
> > > > > > 
> > > > > > {{if not auth.user:}}
> > > > > >     
> > > > > >     
> > > > > >         Login
> > > > > >     
> > > > > >     
> > > > > >         Password
> > > > > >     
> > > > > >     
> > > > > >          > > > > > checked="checked">remember me
> > > > > >     
> > > > > >     {{=form.hidden_fields()}}
> > > > > >     
> > > > > >         
> > > > > >     
> > > > > >     
> > > > > > {{else:}}
> > > > > >     logout
> > > > > > {{pass}}
> > > > > > 
>
> > > > > > By url /default/login it works fine, but when I include it in
> > > > > > layout.html with
> > > > > > {{=LOAD('default','login', vars=request.vars, ajax=False)[0][0]}}
> > > > > > it doesn't log user in.
>
> > > > > > How to make it works? thx