[web2py] Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread BrendanC
I'm trying to retrieve some summary data via an Ajax request with the 
following controller method.
This is just a simple result set containing a list of tag names and usage 
counts retrieved in a JOIN query. Here's the code:

def gettagsummary():
'''
Get list of tags and related counts (from tagref table) - user can then 
view by tag
(similar to Stack Overflow tag view??) 
'''

count = db.tagref.tag.count()
tagsummary = db(db.tagref.tag==db.tag.id).select(db.tagref.tag, 
db.tag.name, count, \
groupby=db.tagref.tag)

return dict(tagsummary=tagsummary)


>From my webpage I make an Ajax/XHR request to get this info in json format 
(the request is url: "/search/gettagsummary.json"

This is what the request response  looks like:

{"tagsummary": [
{"tagref": {"tag": 1}, "tag": {"name": "Places"}, "_extra": 
{"COUNT(tagref.tag)": 4}}, 

{"tagref": {"tag": 2}, "tag": {"name": "Cars"}, "_extra": 
{"COUNT(tagref.tag)": 2}}, 
'
.
.
.
{"tagref": {"tag": 9}, "tag": {"name": "France"}, "_extra": 
{"COUNT(tagref.tag)": 2}}, 
{"tagref": {"tag": 10}, "tag": {"name": "UK"}, "_extra": 
{"COUNT(tagref.tag)": 2}}
]}

OK - so far, so good. Now I need to extract the count info in my Ajax 
response - However the count info is not easily (AFAIK) accessible - the 
'_extra' structure is a web2py artifact that looks odd. I'm thinking there 
must be a better way to pass the count info to my view (e.g. {"count":4}. 

So how do I change this so I can reference the count info. Do I need to 
change my controller code, or is there some (undocumented) way to reference 
the '_extra' info in the json response. 

I can't see anything in the docs on this - so hopefully someone here can 
point me in the right direction here. 

TIA,
BrendanC


[web2py] Re: Virtual Fields and usual database's Views

2011-11-08 Thread BrendanC
Daniel,
Not sure what you are asking, but this might help you:

Virtual fields are otherwise known as 'computed columns' in database terms 
- if that is what you are familiar with. e.g. Sum, Count, Min, Max, etc as 
these values are derived from underlying table data in a database.

A database view is something entirely different - think of it as a virtual 
table or a stored query than can expose either a subset of table columns or 
a query that joins multiple tables and shows just the columns you want. 
Views are very commonly used in legacy type applications (for security and 
performance reasons - e.g. hide the employee salary info by creating a view 
that excludes that data element). 

In the world of web development (Web2py, Django, Rails etc) database access 
is managed primarily by ORM's. For the  most part these are not very 'View' 
friendly - you have to jump through a few hoops to use a view and there are 
some also potential maintenance issues.  (FWIW views are very useful for 
simplifying complex queries and it's a pity that they are not well 
supported in most web environments).

Hope this helps,
BrendanC


 


Re: [web2py] Mixing/supporting CMS with Web2py

2011-11-08 Thread Vinicius Assef
I can help with docs.

On Tue, Nov 8, 2011 at 2:44 AM, ~redShadow~  wrote:
> I have quite large experience with Drupal, which I used since 2006 tu
> build pretty much everything web-related, from websites to applications,
> often using it more as a framework than a CMS.
> That project is great, but IMHO it has some drawbacks.
> The first that comes to mind:
>
> * Not-so-elegant code, derived from the fact that's php-based
> * Structure and data too much mixed up, due to the will to make
> everything configurable from the admin panel.
> * Excessive setup time. Many times 3rd-part modules (sometimes even
> needed to add missing important features to the core) tend to conflict
> or miss something -> many times there is need to develop a custom
> site-specific module in order to simplify things.
> * Lack of enterpriseness in 3rd-part modules: they are not "verified"
> that much, and sometimes bad things happen, even with stuff that used to
> work and must have continued to do so.
>
> So, I recently started doing some experiments to see "how hard would it
> be" to rewrite Drupal web2py-based and with some improvements.
>
> At the moment, I have a simple app that, along with
> garbage/experiments/stuff does pretty much this:
>
> * CRUD for different content-types (each content type may be treated in
> different ways / define extra fields / ..; some examples may be
> "article", "page", "ecommerce product", ...).
> * Commenting. It is handled in a component-like way, although I haven't
> written a proper component yet, I'm using a similar way to attach
> comments + comment form to "entities", that might be not only "content".
> * Regions + blocks. In a way similar to what Drupal does, the
> layout.html defines some regions (sidebars, footer, before/after
> content, before/after page, ...) in which some "blocks" may be placed,
> then blocks are shown independently from the controller (and only in the
> html views, since they wouldn't make much sense, for example, in a json
> or xml representation).
> * Configuration stored in INI files (and maybe in database too, I have
> to decide that).
> * Some rudimental support (I still have to decide what's the best way to
> do that) to user-defined (in the configuration) "views": a mix of
> database query + templates to create custom visualizations of content.
>
> I'm going to release all the code as soon as I finish adding access
> control, so that I can also install a demo site somewhere (shouldn't
> take long, it should only be matter of adding a few decorators..).
>
>
> I think we should also start organizing the development of the CMS
> application:
> - who's up for development?
> - who's up for testing?
> - who's up for documentation? (developers should! documentation is
> awesome! I already wrote more documentation than code for this CMS!)
> - should we setup a project page / wiki / bugtracker / ..? I think that
> it would be a good idea to have at least a wiki, for the moment, on
> which to write all the ideas / misc brainstorming, in order to discuss
> about the important decisions that should be taken before starting the
> actual development.
> - should we create another mailing-list just for the cms thing, in order
> to keep separate the discussions?
> - Do you guys use IRC? I see a #web2py channel on freenode but, although
> there is always some people in it, I never saw pretty much anybody
> speaking in there..
>
> --
> Samuele ~redShadow~ Santi
> 
>     redshadow[at]hackzine.org - redshadowhack[at]gmail.com
>
>  Blog: http://hackzine.org
>
>  GPG Key signature:
>       050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933
> 
> /me recommends:
>    Squadra Informatica - http://www.squadrainformatica.com
> 
>  - Proud ThinkPad T-Series owner
>  - Registered Linux-User: #440008
>      * GENTOO User since 1199142000 (2008-01-01)
>      * former DEBIAN SID user
> 
>      "Software is like sex: it's better when it's free!"
>                              -- Linus Torvalds
>
>


[web2py] Janrain Social Widget Setup

2011-11-08 Thread thodoris
Hello,

I am trying to integrate the Janrain Social Widget to my project.

For the moment i have user authentication with Janrain but i am having
problems adding the Social Widget.

The instructions from Janrain say:

1) Download the rpx_xdcomm.html file and place it in the root
directory of your website.

2) Copy and paste this block of code into the page you want to invoke
the widget from:

  ...
  RPXNOW.init({appId: 'aeebhlpldndcpmloacee',
xdReceiver: '/rpx_xdcomm.html'});

3) Invoke the widget

I followed the above steps but i get the following:

Error: unable to load http://127.0.0.1:8000/rpx_xdcomm.html

Where should i put rpx_xdcomm.html ??? and what does "root directory
of your website" means?

I am running all using the incorporated web server in web2py.

Any help???


[web2py] Authentication

2011-11-08 Thread Nils Olofsson
Hi,

Just wondering if this is possible, I think it should be...

I have  a  2 web2py application, but i want them to have a common
authentication db.

I was thinking of doing this in the model DB for both.

authdb = DAL('mysql database')

Then

auth = Auth(globals(),authdb)

I have now tested this but would this work ?

Nils


Re: [web2py] Mixing/supporting CMS with Web2py

2011-11-08 Thread Kenneth Lundström

I'm also very interested in getting more CMS functions into web2py.

I can help with:
- testing
- server resources if needed
- setting up bugtracker, wikipage

I think a own mailinglist and a wiki page first. Very soon a bugtracker. 
Maybe a web2py based bugtracker.



Kenneth


I have quite large experience with Drupal, which I used since 2006 tu
build pretty much everything web-related, from websites to applications,
often using it more as a framework than a CMS.
That project is great, but IMHO it has some drawbacks.
The first that comes to mind:

* Not-so-elegant code, derived from the fact that's php-based
* Structure and data too much mixed up, due to the will to make
everything configurable from the admin panel.
* Excessive setup time. Many times 3rd-part modules (sometimes even
needed to add missing important features to the core) tend to conflict
or miss something ->  many times there is need to develop a custom
site-specific module in order to simplify things.
* Lack of enterpriseness in 3rd-part modules: they are not "verified"
that much, and sometimes bad things happen, even with stuff that used to
work and must have continued to do so.

So, I recently started doing some experiments to see "how hard would it
be" to rewrite Drupal web2py-based and with some improvements.

At the moment, I have a simple app that, along with
garbage/experiments/stuff does pretty much this:

* CRUD for different content-types (each content type may be treated in
different ways / define extra fields / ..; some examples may be
"article", "page", "ecommerce product", ...).
* Commenting. It is handled in a component-like way, although I haven't
written a proper component yet, I'm using a similar way to attach
comments + comment form to "entities", that might be not only "content".
* Regions + blocks. In a way similar to what Drupal does, the
layout.html defines some regions (sidebars, footer, before/after
content, before/after page, ...) in which some "blocks" may be placed,
then blocks are shown independently from the controller (and only in the
html views, since they wouldn't make much sense, for example, in a json
or xml representation).
* Configuration stored in INI files (and maybe in database too, I have
to decide that).
* Some rudimental support (I still have to decide what's the best way to
do that) to user-defined (in the configuration) "views": a mix of
database query + templates to create custom visualizations of content.

I'm going to release all the code as soon as I finish adding access
control, so that I can also install a demo site somewhere (shouldn't
take long, it should only be matter of adding a few decorators..).


I think we should also start organizing the development of the CMS
application:
- who's up for development?
- who's up for testing?
- who's up for documentation? (developers should! documentation is
awesome! I already wrote more documentation than code for this CMS!)
- should we setup a project page / wiki / bugtracker / ..? I think that
it would be a good idea to have at least a wiki, for the moment, on
which to write all the ideas / misc brainstorming, in order to discuss
about the important decisions that should be taken before starting the
actual development.
- should we create another mailing-list just for the cms thing, in order
to keep separate the discussions?
- Do you guys use IRC? I see a #web2py channel on freenode but, although
there is always some people in it, I never saw pretty much anybody
speaking in there..





[web2py] uploads folder is empty

2011-11-08 Thread Alex
I don't know why, but when I upload an image, the uploads folder is
empty !

In my table I can see  :
FieldStorage('800x480', 'a800x480.jpg', '\xff\x . xe0\x00')

In my view I'm doing this :

{{=myTable.name}}

I can see the name of my image, but no image (that makes sense because
my uploads folder is empty)

I'm on Linux, I did "chmod 777 uploads", but still same pb

Is there a configuration that I forgot to do ?


db.define_table('image',
  Field('name', length=45),
  Field('image', 'upload'),
)


Re: [web2py] Re: Virtual Fields and usual database's Views

2011-11-08 Thread danto
2011/11/8 BrendanC 

> Daniel,
> Not sure what you are asking, but this might help you:
>
> Virtual fields are otherwise known as 'computed columns' in database terms
> - if that is what you are familiar with. e.g. Sum, Count, Min, Max, etc as
> these values are derived from underlying table data in a database.
>
> A database view is something entirely different - think of it as a virtual
> table or a stored query than can expose either a subset of table columns or
> a query that joins multiple tables and shows just the columns you want.
> Views are very commonly used in legacy type applications (for security and
> performance reasons - e.g. hide the employee salary info by creating a view
> that excludes that data element).
>
>
I don't know when I start confusing Virtual Fields with Virtual Tables, an
so I was overestimating what I can do with Virtual Fields.

When you said "is commonly used in legacy applications" you mean that now
they are not used very much? IIRC, Views are a lot faster than doing a Join
from the app.


> In the world of web development (Web2py, Django, Rails etc) database
> access is managed primarily by ORM's. For the  most part these are not very
> 'View' friendly - you have to jump through a few hoops to use a view and
> there are some also potential maintenance issues.  (FWIW views are very
> useful for simplifying complex queries and it's a pity that they are not
> well supported in most web environments).
>
> Hope this helps,
> BrendanC
>
>

I'm agree with you. I also can't understand why Databases Views are not so
important in Web2py (et al). The only way I see to use Database's Views in
web2py is with db.extecutesql statement. I hope some other can answer us.

Thank you Brendan! You helped me a lot.


Re: [web2py] Re: Virtual Fields and usual database's Views

2011-11-08 Thread Daniel Aguayo
2011/11/8 danto   that was me, sorry

>
> 2011/11/8 BrendanC 
>
>> Daniel,
>> Not sure what you are asking, but this might help you:
>>
>> Virtual fields are otherwise known as 'computed columns' in database
>> terms - if that is what you are familiar with. e.g. Sum, Count, Min, Max,
>> etc as these values are derived from underlying table data in a database.
>>
>> A database view is something entirely different - think of it as a
>> virtual table or a stored query than can expose either a subset of table
>> columns or a query that joins multiple tables and shows just the columns
>> you want. Views are very commonly used in legacy type applications (for
>> security and performance reasons - e.g. hide the employee salary info by
>> creating a view that excludes that data element).
>>
>>
> I don't know when I start confusing Virtual Fields with Virtual Tables, an
> so I was overestimating what I can do with Virtual Fields.
>
> When you said "is commonly used in legacy applications" you mean that now
> they are not used very much? IIRC, Views are a lot faster than doing a Join
> from the app.
>
>
>> In the world of web development (Web2py, Django, Rails etc) database
>> access is managed primarily by ORM's. For the  most part these are not very
>> 'View' friendly - you have to jump through a few hoops to use a view and
>> there are some also potential maintenance issues.  (FWIW views are very
>> useful for simplifying complex queries and it's a pity that they are not
>> well supported in most web environments).
>>
>> Hope this helps,
>> BrendanC
>>
>>
>
> I'm agree with you. I also can't understand why Databases Views are not so
> important in Web2py (et al). The only way I see to use Database's Views in
> web2py is with db.extecutesql statement. I hope some other can answer us.
>
> Thank you Brendan! You helped me a lot.
>
>


-- 
Daniel Aguayo
@dantoac
GNU/Linux User #387337


[web2py] Re: Authentication

2011-11-08 Thread David Marko
Yes, you can use CAS pointed to just one application ... very easy to setup 
... see here
http://www.web2py.com/book/default/chapter/08#Central-Authentication-Service


Re: [web2py] Authentication

2011-11-08 Thread Bruno Rocha
Yes it works well.

You can also use *cas* to share authentication between applications.

But the approach using same db for both applications is better, but note
that both applications should have the same *hmac_key* for auth instance.

On Tue, Nov 8, 2011 at 9:06 AM, Nils Olofsson wrote:

> Hi,
>
> Just wondering if this is possible, I think it should be...
>
> I have  a  2 web2py application, but i want them to have a common
> authentication db.
>
> I was thinking of doing this in the model DB for both.
>
> authdb = DAL('mysql database')
>
> Then
>
> auth = Auth(globals(),authdb)
>
> I have now tested this but would this work ?
>
> Nils
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
In layout.html, I have
{{response.files.append(URL(r=request,c='static',f='js/xyz.js'))}}
xyz.js contains a function abc(){ code line1; code line 2;

In a View, there is -->   ajax('{{=URL("salhead_edit")}}, [],
':eval');

"salhead_edit" returns js function -->  'abc(myvar1)'
But it is not evaluated in View.
(I am sure that the js file is correctly referenced in layout.html)

Note: If I directly return the "code line1; code line 2;..." from the
controller, they ARE evaluated. But "function abc()" is not returned.
Is it expected behaviour of the ajax function?

Regards,
Vineet


Re: [web2py] Mixing/supporting CMS with Web2py

2011-11-08 Thread Ross Peoples
I can help with development. We need this functionality. Sort of like a 
reverse Drupal in that web2py would be a framework that also does CMS.

[web2py] ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
In layout.html, I have
{{response.files.append(URL(r=request,c='static',f='js/xyz.js'))}}
xyz.js contains a function abc(){ code line1; code line 2;

In a View, there is -->   ajax('{{=URL("salhead_edit")}}, [],
':eval');

"salhead_edit" returns js function -->  'abc(myvar1)'
But it is not evaluated in View.
(I am sure that the js file is correctly referenced in layout.html)


Note: If I directly return the "code line1; code line 2;..." from the
controller, they ARE evaluated. But "function abc()" is not
evaluated.
Is it expected behaviour of the ajax function?


Regards,
Vineet



[web2py] ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
In layout.html, I have
{{response.files.append(URL(r=request,c='static',f='js/xyz.js'))}}

xyz.js contains a function abc(x){ code line1; code line 2;

In a View, there is -->   ajax('{{=URL("salhead_edit")}}, [],
':eval');

"salhead_edit" returns js function -->  'abc(myvar1)'
But it is not evaluated in View.
(I am sure that the js file is correctly referenced in layout.html)

Note: If I directly return the "code line1; code line 2;..." from the
controller, they ARE evaluated.
But "function abc()" is not evaluated.

Is it expected behaviour of the ajax function?

Regards,
Vineet


[web2py] Re: uploads folder is empty

2011-11-08 Thread Anthony
It looks like you have attempted to directly store the cgi.FieldStorage 
object in the db field, which won't work. Please show the code used to get 
the file uploaded.

On Tuesday, November 8, 2011 6:16:11 AM UTC-5, Alex wrote:
>
> I don't know why, but when I upload an image, the uploads folder is 
> empty ! 
>
> In my table I can see  : 
> FieldStorage('800x480', 'a800x480.jpg', '\xff\x . xe0\x00') 
>
> In my view I'm doing this : 
>  
> {{=myTable.name}} 
>
> I can see the name of my image, but no image (that makes sense because 
> my uploads folder is empty) 
>
> I'm on Linux, I did "chmod 777 uploads", but still same pb 
>
> Is there a configuration that I forgot to do ? 
>
>
> db.define_table('image', 
>   Field('name', length=45), 
>   Field('image', 'upload'), 
> ) 
>


Re: [web2py] Authentication

2011-11-08 Thread David Marko
How this sharing one database works with SQLLite file lockig?

Re: [web2py] Authentication

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 7:08:08 AM UTC-5, rochacbruno wrote:
>
> Yes it works well.
>
> You can also use *cas* to share authentication between applications.
>
> But the approach using same db for both applications is better, but note 
> that both applications should have the same *hmac_key* for auth instance.
>

Also, make sure all applications but one turn off migrations for the Auth 
tables. If the db connection is exclusively for accessing the Auth tables, 
you can disable migrations for the whole connection via:

authdb = DAL('mysql database', migrate_enabled=False)

Alternatively, you can disable migrations for the individual Auth tables 
(but not other tables accessed by the connection via:

auth.define_tables(migrate=False)

I could be wrong, but I think simply sharing the db for Auth tables would 
still require separate logins for each app, whereas I think using CAS, a 
single login would keep you logged into both apps at once.

Anthony



[web2py] sqlform.grid

2011-11-08 Thread JmiXIII
Hello,

I have something like:

selection=FORM(TABLE(TR(
TD('Début',INPUT(_name='Deb'),_class="date", requires = 
IS_DATE(error_message=T('Doit être de la forme -MM-JJ !'))),
TD('Fin',INPUT(_name='Fin',_class="date", requires = 
IS_DATE(error_message=T('Doit être de la forme -MM-JJ !',

TD('Famille',SELECT('Frappe','Reprise','Tri',_name='Famille')),
TD(INPUT(_type='submit',_value='Sélectionner'))
)))
Deb=request.vars.Deb
Fin=request.vars.Fin
Famille=request.vars.Famille
Ct=0
query1=db.Rebuts.Date>=Deb
query2=db.Rebuts.Date<=Fin
query3=db.Rebuts.Famille==Famille
if Famille=='Tri' : 
query3=(db.Rebuts.Machine=='TRI')&(db.Rebuts.Famille=='NQ')
if Famille=='Reprise' : 
query3=(db.Rebuts.Famille!='NQ')&(db.Rebuts.Famille!='Frappe')
query=query1&query2&query3
records=db(query).select()
for record in records:
Ct=Ct+record.CtReb
if selection.accepts(request.vars,keepvalues=True):
pass
form=SQLFORM.grid(query)
return dict(selection=selection,Ct=Ct,form=form


Everything is all right except, I can't paginate with sqlform.grid 
(selection form data seems to be lost).
Can somebody give a way to solve it ?
Thanks in advance



[web2py] Re: sqlform.grid

2011-11-08 Thread JmiXIII
Sorry I open a new discussion


[web2py] SQLFORM.grid and query

2011-11-08 Thread JmiXIII
Hello,

I have something like:

selection=FORM(TABLE(TR(
TD('Début',INPUT(_name='Deb'),
_class="date", requires = IS_DATE(error_message=T('Doit être de la forme 
-MM-JJ !'))),
TD('Fin',INPUT(_name='Fin',_class="date", requires = 
IS_DATE(error_message=T('Doit être de la forme -MM-JJ !',

TD('Famille',SELECT('Frappe','Reprise','Tri',_name='Famille')),
TD(INPUT(_type='submit',_value='Sélectionner'))
)))
Deb=request.vars.Deb
Fin=request.vars.Fin
Famille=request.vars.Famille
Ct=0
query1=db.Rebuts.Date>=Deb
query2=db.Rebuts.Date<=Fin
query3=db.Rebuts.Famille==Famille
if Famille=='Tri' : 
query3=(db.Rebuts.Machine=='TRI')&(db.Rebuts.Famille=='NQ')
if Famille=='Reprise' : 
query3=(db.Rebuts.Famille!='NQ')&(db.Rebuts.Famille!='Frappe')
query=query1&query2&query3
records=db(query).select()
for record in records:
Ct=Ct+record.CtReb
if selection.accepts(request.vars,keepvalues=True):
pass
form=SQLFORM.grid(query)
return dict(selection=selection,Ct=Ct,form=form


Everything is all right except, I can't paginate with sqlform.grid 
(selection form data seems to be lost).
Can somebody give a way to solve it ?
Thanks in advance


[web2py] auth.settings.login_next not working on ldap authentication

2011-11-08 Thread Tito Garrido
Hi folks!

I'm trying to redirect to a different page after login using ldap
authentication but it just sends me to index... is it a bug?

Regards,

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 7:45:59 AM UTC-5, Vineet wrote:
>
> In a View, there is -->   ajax('{{=URL("salhead_edit")}}, [], 
> ':eval');
>

Probably a typo, but missing the closing single quote (') after the }} for 
the URL.
 

> "salhead_edit" returns js function -->  'abc(myvar1)'
>

Unless 'myvar1' is a variable already defined in javascript somewhere in 
your page, that won't work. If 'myvar' is a Python variable, you're going 
to have to insert its actual value (in quotes if it is a string) into the 
JS code. Remember, from web2py's perspective in the controller, the JS code 
you're building is simply a string -- it doesn't know it is code. Something 
like:

myvar1 = 'whatever'
js = 'abc("%s");' % myvar1

will return:

abc("whatever");

Note, it's a good idea to add the ";" at the end of the line.

Anthony


[web2py] Re: Numbers Format

2011-11-08 Thread Franklin Freitas
Hi Vinicius,

You mean I can use str.format() to format numbers with thousand
separators instead of my function ?, that would be great Could you
give me an example ??

Thanks

On Nov 7, 6:42 pm, Vinicius Assef  wrote:
> Possibly the python version in your production server.
>
> str.format() is available since python 2.6.
>
> --
> Vinicius Assef.
>
> On Mon, Nov 7, 2011 at 7:41 PM,FranklinFreitas
>
>
>
>
>
>
>
>  wrote:
> > In order to format numbers with thousands separator and custom number
> > of decimals, I created the following function and included it in my
> > "db.py" model so it could be accessed through the entire application.
>
> > def number_format(num, places=0):
> >    return locale.format("%.*f", (places, num), True)
>
> > I use it my views like:
>
> > {{=number_format(x.vebamt,2)}}
>
> > It works great in my development environment, but after migrating it
> > to production (I am using a linode vps) the function doesn't work, I
> > doesn't give me an error, it just doesn't format the numbers.
>
> > Any ideas what could be wrong ? I searched the group for a solution
> > for formatting numbers and didn't find a previous post on this matter
>
> > Thanks for your help
>
> >Franklin


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
> Probably a typo, but missing the closing single quote (') after the }} for
> the URL.

It is a typo here. It is correct in actual code.

> If 'myvar' is a Python variable, you're going

'myvar' is a not a python variable.
I pass the id of html element as argument.
Javascript code sets the value of that html element.

>From your reply, I guess that it is OK to return a javascript function
from controller (the way I did), provided that I adhere to your hints.

Perhaps then, why my code is failing to evaluate js function in View?

Regards,
Vineet


On Nov 8, 6:05 pm, Anthony  wrote:
> On Tuesday, November 8, 2011 7:45:59 AM UTC-5, Vineet wrote:
>
> > In a View, there is -->   ajax('{{=URL("salhead_edit")}}, [],
> > ':eval');
>
> Probably a typo, but missing the closing single quote (') after the }} for
> the URL.
>
> > "salhead_edit" returns js function -->  'abc(myvar1)'
>
> Unless 'myvar1' is a variable already defined in javascript somewhere in
> your page, that won't work. If 'myvar' is a Python variable, you're going
> to have to insert its actual value (in quotes if it is a string) into the
> JS code. Remember, from web2py's perspective in the controller, the JS code
> you're building is simply a string -- it doesn't know it is code. Something
> like:
>
> myvar1 = 'whatever'
> js = 'abc("%s");' % myvar1
>
> will return:
>
> abc("whatever");
>
> Note, it's a good idea to add the ";" at the end of the line.
>
> Anthony


[web2py] Re: web(2/3)-based CMS

2011-11-08 Thread Gour
On Mon, 7 Nov 2011 05:41:23 -0800 (PST)
Ross Peoples 
wrote:

> Since I would regularly use and CMS/Blog functionality, I would be
> happy to contribute code and test it, as I would probably be using it
> every day. I would also have regular users play with it and
> incorporate their feedback into it to make something that is better
> than WordPress and Drupal combined. 

Same here...If we agree to work on such a thing, it means I'll fully focus on
using web2py solely for all my web needs (which I very much prefer over
fiddling with concrete5/wordpress), learn web2py, write add-ons, writing docs,
testing, translating...


Sincerely,
Gour


-- 
In the material world, one who is unaffected by whatever good 
or evil he may obtain, neither praising it nor despising it, 
is firmly fixed in perfect knowledge.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature


Re: [web2py] Authentication

2011-11-08 Thread Bruno Rocha
if you store sessions in a shared database you can be logged in both apps.

I still have no success running cas with a custom auth table.

http://zerp.ly/rochacbruno
Em 08/11/2011 10:55, "Anthony"  escreveu:

> On Tuesday, November 8, 2011 7:08:08 AM UTC-5, rochacbruno wrote:
>>
>> Yes it works well.
>>
>> You can also use *cas* to share authentication between applications.
>>
>> But the approach using same db for both applications is better, but note
>> that both applications should have the same *hmac_key* for auth instance.
>>
>
> Also, make sure all applications but one turn off migrations for the Auth
> tables. If the db connection is exclusively for accessing the Auth tables,
> you can disable migrations for the whole connection via:
>
> authdb = DAL('mysql database', migrate_enabled=False)
>
> Alternatively, you can disable migrations for the individual Auth tables
> (but not other tables accessed by the connection via:
>
> auth.define_tables(migrate=False)
>
> I could be wrong, but I think simply sharing the db for Auth tables would
> still require separate logins for each app, whereas I think using CAS, a
> single login would keep you logged into both apps at once.
>
> Anthony
>
>


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote:
>
> > If 'myvar' is a Python variable, you're going 
>
> 'myvar' is a not a python variable. 
> I pass the id of html element as argument. 
> Javascript code sets the value of that html element.


OK, but same problem -- 'myvar1' isn't a javascript variable either -- it 
is a string identifying an html element. So you would still have to return 
'abc("myvar1")', or maybe 'abc("#myvar1")', depending on how you are using 
it in the code.

Anthony


Re: [web2py] Authentication

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 8:44:07 AM UTC-5, rochacbruno wrote:
>
> if you store sessions in a shared database you can be logged in both apps.
>
Oh, right.
 

> I still have no success running cas with a custom auth table.
>
Did you submit an issue?



Re: [web2py] Authentication

2011-11-08 Thread nils
Hi,

Ok this sound good, I figured i could, I was thinking of storing
session in database, but I don't think user will be logged into the 2
apps at the same time, and I don't really want a complicated CAS
setup.

Regards,
Nils


On Tue, Nov 8, 2011 at 12:55 PM, Anthony  wrote:
> On Tuesday, November 8, 2011 7:08:08 AM UTC-5, rochacbruno wrote:
>>
>> Yes it works well.
>> You can also use cas to share authentication between applications.
>> But the approach using same db for both applications is better, but note
>> that both applications should have the same hmac_key for auth instance.
>
> Also, make sure all applications but one turn off migrations for the Auth
> tables. If the db connection is exclusively for accessing the Auth tables,
> you can disable migrations for the whole connection via:
> authdb = DAL('mysql database', migrate_enabled=False)
>
> Alternatively, you can disable migrations for the individual Auth tables
> (but not other tables accessed by the connection via:
> auth.define_tables(migrate=False)
> I could be wrong, but I think simply sharing the db for Auth tables would
> still require separate logins for each app, whereas I think using CAS, a
> single login would keep you logged into both apps at once.
> Anthony
>


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
Something is wrong in the function.
I defined a test js function in View.

function alrt(mesg) {
alert(mesg) };

And in Controller,
return "alrt('Hello World!');"

It works.

The actual js function is---
(it sees which value of select box matches the one returned from
controller; then sets the value of select box to that value).

function selbx(elementID, value_returned_from_dataset){
for (i=0;i wrote:
> On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote:
>
> > > If 'myvar' is a Python variable, you're going
>
> > 'myvar' is a not a python variable.
> > I pass the id of html element as argument.
> > Javascript code sets the value of that html element.
>
> OK, but same problem -- 'myvar1' isn't a javascript variable either -- it
> is a string identifying an html element. So you would still have to return
> 'abc("myvar1")', or maybe 'abc("#myvar1")', depending on how you are using
> it in the code.
>
> Anthony


Re: [web2py] Re: Numbers Format

2011-11-08 Thread Vinicius Assef
No. I said probably you're using format() in a version it is not
supported yet. But I'm not sure about it.

I never lay on server locale dependancy.

I live in Brazil, and here we have numbers formatted this way:
"1.000,00". (dot separates thousands. Comma separates decimal).
So, I did this simple funcion:
def g_brazilian_decimal(s):
return s.replace('.', '*').replace(',', '.').replace('*', ',')

And when I need to show some decimal data, I call:
{{=g_brazilian_decimal('%.2f' % row.my_decimal_field)}}

I don't know if your need is alike mine, but this is how I manage it.

--
Vinicius Assef.



On Tue, Nov 8, 2011 at 11:10 AM, Franklin Freitas
 wrote:
> Hi Vinicius,
>
> You mean I can use str.format() to format numbers with thousand
> separators instead of my function ?, that would be great Could you
> give me an example ??
>
> Thanks
>
> On Nov 7, 6:42 pm, Vinicius Assef  wrote:
>> Possibly the python version in your production server.
>>
>> str.format() is available since python 2.6.
>>
>> --
>> Vinicius Assef.
>>
>> On Mon, Nov 7, 2011 at 7:41 PM,FranklinFreitas
>>
>>
>>
>>
>>
>>
>>
>>  wrote:
>> > In order to format numbers with thousands separator and custom number
>> > of decimals, I created the following function and included it in my
>> > "db.py" model so it could be accessed through the entire application.
>>
>> > def number_format(num, places=0):
>> >    return locale.format("%.*f", (places, num), True)
>>
>> > I use it my views like:
>>
>> > {{=number_format(x.vebamt,2)}}
>>
>> > It works great in my development environment, but after migrating it
>> > to production (I am using a linode vps) the function doesn't work, I
>> > doesn't give me an error, it just doesn't format the numbers.
>>
>> > Any ideas what could be wrong ? I searched the group for a solution
>> > for formatting numbers and didn't find a previous post on this matter
>>
>> > Thanks for your help
>>
>> >Franklin


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
I checked the js returned from controller function.
It is
selbx('edit_freq','daily');

selbx function is there in the View.

-- Vineet

On Nov 8, 7:04 pm, Vineet  wrote:
> Something is wrong in the function.
> I defined a test js function in View.
>
> function alrt(mesg) {
> alert(mesg) };
>
> And in Controller,
> return "alrt('Hello World!');"
>
> It works.
>
> The actual js function is---
> (it sees which value of select box matches the one returned from
> controller; then sets the value of select box to that value).
>
> function selbx(elementID, value_returned_from_dataset){
>             for (i=0;i              {
>                 if (value_returned_from_dataset ==
> document.getElementById(elementID).options(i).text)
>
> {document.getElementById(elementID).options(i).selected = true;
>
>                      }}}
>
> In controller---
> return "selbx('id_of_element','%s');" % dict_obj['freq']
>
> dict_obj['freq'] is non-blank.
> It is a string itself.
> 
> If individual code-lines are returned, it works.
> 
>
> Any guess why so?
>
> Regards,
> Vineet
>
> On Nov 8, 6:44 pm, Anthony  wrote:
>
>
>
> > On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote:
>
> > > > If 'myvar' is a Python variable, you're going
>
> > > 'myvar' is a not a python variable.
> > > I pass the id of html element as argument.
> > > Javascript code sets the value of that html element.
>
> > OK, but same problem -- 'myvar1' isn't a javascript variable either -- it
> > is a string identifying an html element. So you would still have to return
> > 'abc("myvar1")', or maybe 'abc("#myvar1")', depending on how you are using
> > it in the code.
>
> > Anthony- Hide quoted text -
>
> - Show quoted text -


[web2py] Using cache.manifest for offline storage

2011-11-08 Thread Harkirat
Has anyone successfully implemented the HTML5 offline storage
capability using web2py running on its native rocket server?
I keep getting a "Application Cache Error event: Invalid manifest mime
type (text/plain) " on Google chrome for the cache.manifest file and I
don't know how to configure the rocket server for mime types. Any
suggestions? Thanks in advance!

Harkirat


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Anthony
I think you need .options[i] rather than .options(i). Anyway, it's 
generally easier to do this kind of thing with jQuery rather than raw 
Javascript.

Anthony

On Tuesday, November 8, 2011 9:04:41 AM UTC-5, Vineet wrote:
>
> Something is wrong in the function. 
> I defined a test js function in View. 
>
> function alrt(mesg) { 
> alert(mesg) }; 
>
> And in Controller, 
> return "alrt('Hello World!');" 
>
> It works. 
>
> The actual js function is--- 
> (it sees which value of select box matches the one returned from 
> controller; then sets the value of select box to that value). 
>
> function selbx(elementID, value_returned_from_dataset){ 
> for (i=0;i  { 
> if (value_returned_from_dataset == 
> document.getElementById(elementID).options(i).text) 
>   
> {document.getElementById(elementID).options(i).selected = true; 
>
>  }}} 
>
> In controller--- 
> return "selbx('id_of_element','%s');" % dict_obj['freq'] 
>
> dict_obj['freq'] is non-blank. 
> It is a string itself. 
>  
> If individual code-lines are returned, it works. 
>  
>
> Any guess why so? 
>
> Regards, 
> Vineet 
>
> On Nov 8, 6:44 pm, Anthony  wrote: 
> > On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote: 
> > 
> > > > If 'myvar' is a Python variable, you're going 
> > 
> > > 'myvar' is a not a python variable. 
> > > I pass the id of html element as argument. 
> > > Javascript code sets the value of that html element. 
> > 
> > OK, but same problem -- 'myvar1' isn't a javascript variable either -- 
> it 
> > is a string identifying an html element. So you would still have to 
> return 
> > 'abc("myvar1")', or maybe 'abc("#myvar1")', depending on how you are 
> using 
> > it in the code. 
> > 
> > Anthony



Re: [web2py] Mixing/supporting CMS with Web2py

2011-11-08 Thread Ovidio Marinho
Here is what you are looking for

 https://github.com/lucasdavila/web2py-cms


Import wordpress xml into web2py-cms automatic, implement ckeditor, and
others functions.

   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil

Apóio



2011/11/8 Ross Peoples 

> I can help with development. We need this functionality. Sort of like a
> reverse Drupal in that web2py would be a framework that also does CMS.


[web2py] Re: web2py with SAE Python

2011-11-08 Thread chinakr
My new index.wsgi is as follow:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sae

from gluon.settings import global_settings
global_settings.web2py_runtime_gae = True

import gluon.main

app = gluon.main.wsgibase
application = sae.create_wsgi_app(app)
#application = app


And I also have to disable open function in gluon/main.py:

#version_info = open(abspath('VERSION', gluon=True), 'r')
#version_info = open('../VERSION')
version_info = 'Version 1.99.2 (2011-09-26 06:55:33) stable'
#web2py_version = parse_version(version_info.read().strip())
web2py_version = parse_version(version_info)
#version_info.close()
global_settings.web2py_version = web2py_version


Now the error is still 'invalid request':
http://web2py.sinaapp.com/welcome/default/index
http://web2py.sinaapp.com/debug


What should I do know?


On Nov 7, 10:30 pm, Massimo Di Pierro 
wrote:
> Try this:
>
> import sae
> import gluon.main
> from gluon.settings import global_settings
> global_settings.web2py_runtime_gae = True
> application = gluon.main.wsgibase
>
> On Nov 7, 1:57 am, chinakr  wrote:
>
>
>
>
>
>
>
> > SAE means Sina App Engine, which is a public cloud computing platform
> > like GAE. It's the most mature and famous public cloud in China, where
> > people can't access GAE freely. SAE only supports PHP in the last 3
> > years.
>
> > Recently, SAE started internal testing with Python support, with code
> > name SAE Python.
>
> > I would like to deploy web2py on SAE Python. And as GAE, SAE Python
> > doesn't provide local file I/O, etc. I have to modify a lot of things
> > manually.
>
> > As lack of experience and time, it seems a hard task for me. So anyone
> > can help?
>
> >http://3.web2py.sinaapp.com/welcome/default/index
> > will get 'invalid request' message with following index.wsgi:
>
> > import sae
> > import gluon.main
>
> > app = gluon.main.wsgibase
> > application = sae.create_wsgi_app(app)
>
> > I also comment mkdir and open code in main.py.
>
> > SAE Python 
> > documents:http://appstack.sinaapp.com/static/doc/release/testing/index.html


Re: [web2py] Re: new web site

2011-11-08 Thread Justin Heath
On page: http://web2py.com/new_examples/default/download
"Nightly Built" should be "Nightly Build"

Otherwise, the site looks very nice.

On Mon, Nov 7, 2011 at 4:31 PM, Omi Chiba  wrote:
> Looks great !
>
> Can you add the link to web2py Japan under Documentation - Community
> sources - Sites ?
>
> web2py Japan
> https://sites.google.com/site/web2pyjapan/
>
> Thanks
>
> On Nov 6, 2:02 pm, Massimo Di Pierro 
> wrote:
>> We have a new web site
>>
>>    http://web2py.com/new_examples
>>
>> Please check it out before we replace the old one.


[web2py] Computed Fields not updating

2011-11-08 Thread David Manns
In my application I use computed fields in two ways. Examples:

Name is represented in record as separate fields, e.g., Title, First
name, Last name, Suffix. Use a computed field to concatenate last+first
+title+suffix and convert to lower case to make a field for use in
sorting for display.

Use a computed boolean to maintain a record of good status, a test on
date and on the value in a string (status description).

The computed fields all work when a record is added (crud.create).

When record is edited (crud.update) the boolean is recomputed but the
string is not.

Stranger even, I made a simple test app with the wizard, then added
computed fields of string, integer, float, boolean to the table model.
In this case, the controller uses SQLFORM.smartgrid.  All the computed
fields work when adding a new record but none of them work on editing
a record??



[web2py] Re: crud update problem with 1.99.2?

2011-11-08 Thread David Manns
Yes, that thread describes the problem.  I had realized it had to do
with the URL and found a different workaround.  Instead of building a
new URL and passing it to crud via next=, I set up an 'onaccept'
function which sets up a session.flash and then redirects as desired.
This is working!  Still, nice that the bug is recognized and will get
fixed.

Thanks for your help

On Nov 7, 1:44 pm, Richard Vézina  wrote:
> This thread might interest you :
>
> http://groups.google.com/group/web2py/browse_thread/thread/f35eeb3c78...
>
> Richard
>
> On Mon, Nov 7, 2011 at 11:38 AM, Richard Vézina 
>
>
>
>
>
>
> > wrote:
> > Did you have a look of what is coming out request.vars.membid and
> > request.vars.next... I maybe not what you expect that you get and it may
> > cause the problem...
>
> > If you test your controller manually does it work properly? If so, it must
> > be a wrong type coming from your request.vars, you can try to convert to
> > the proper type int(request.vars.membid) for example.
>
> > Richard
>
> > On Mon, Nov 7, 2011 at 10:44 AM, David Manns  wrote:
>
> >> I don't think its to do with the model (the table in question has no
> >> float or decimal in any case).
>
> >> I think it has to do with the handling of next= in crud.
>
> >> The controller code (somewhat simplified, but still reproduces the
> >> problem) is:
>
> >> def memberform():
> >>        if request.vars.membid:
> >>                 next = URL('memberform',
> >> vars=dict(membid=request.vars.membid,
> >> next=request.vars.next))
> >>                 form = crud.update(db.Members, request.vars.membid,
> >> next=next)
> >>        else:
> >>                form = crud.create(db.Members, next=request.vars.next)
> >>        return dict(form=form, next=request.vars.next,
> >> membid=request.vars.membid)
>
> >> The first time in, with membid the ID of an existing record, the
> >> record is correctly displayed via the crud.update() form.  When a
> >> field is edited and the form submitted, the failure occurs.
>
> >> On Oct 28, 7:59 am, Richard Vézina 
> >> wrote:
> >> > Without model I think it difficult to debug...
>
> >> > But the problem come from a float type error, so there must be a failing
> >> > constrain on one of your field... Look at you member model if there is a
> >> > double type field or decimal and make sure you have a validator with
> >> > appropriate constraining domain...
>
> >> > doubleIS_FLOAT_IN_RANGE(-1e100,
> >> 1e100)decimal(n,m)IS_DECIMAL_IN_RANGE(-1e100,
> >> > 1e100)
> >> > Richard
>
> >> > On Sat, Oct 15, 2011 at 10:15 AM, David Manns 
> >> wrote:
> >> > > This problem appeared when I moved my application from x to 1.99.2.
>
> >> > > I use crud.update to display and modify a member directory record.
> >> > > Selecting and displaying the record works, but when submitting an
> >> updated
> >> > > record I get a failure:
>
> >> > > TRACEBACK
>
> >> > > 1.
> >> > > 2.
> >> > > 3.
> >> > > 4.
> >> > > 5.
> >> > > 6.
> >> > > 7.
> >> > > 8.
> >> > > 9.
> >> > > 10.
> >> > > 11.
> >> > > 12.
>
> >> > > Traceback (most recent call last):
> >> > >   File "C:\Documents and Settings\David Manns\My
> >> Documents\ocsnedb\gluon\restricted.py", line 194, in restricted
> >> > >     raise
> >> > >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb
> >> saved/applications/init/controllers/default.py" <
> >>http://127.0.0.1:8000/admin/default/edit/init/controllers/default.py>,
> >> line 889, in 
> >> > >   File "C:\Documents and Settings\David Manns\My
> >> Documents\ocsnedb\gluon\globals.py", line 149, in 
> >> > >   File "C:/Documents and Settings/David Manns/My Documents/ocsnedb
> >> saved/applications/init/controllers/default.py" <
> >>http://127.0.0.1:8000/admin/default/edit/init/controllers/default.py>,
> >> line 273, in memberform
> >> > >     deletable = False, next=next, onvalidation=setmodified)
> >> > >   File "C:\Documents and Settings\David Manns\My
> >> Documents\ocsnedb\gluon\tools.py", line 2994, in update
> >> > >     formname=DEFAULT,
> >> > >   File "C:\Documents and Settings\David Manns\My
> >> Documents\ocsnedb\gluon\tools.py", line 79, in replace_id
> >> > > TypeError: float argument required
>
> >> > > The controller code looks like:
>
> >> > > def memberform():
> >> > >  chkurlreader()
> >> > >  if request  >> >.vars.membid:
> >> > >      member=db.Members[request <
> >>http://127.0.0.1:8000/examples/global/vars/request>.vars.membid]
> >> > >      db.Members.Email.comment = A <
> >>http://127.0.0.1:8000/examples/global/vars/A>('Add/Edit/Delete Email
> >> Address(es)',
> >> > >          _href=URL 
> >> > > ('memberemail',
> >> vars=dict(membid=request <
> >>http://127.0.0.1:8000/examples/global/vars/request>.vars.membid,
> >> next=request  >> >.vars.next)))
> >> > >      db.Members.Affiliation.comment = A <
> >>http://127.0.0.1:8000/examples/g

[web2py] Re: Windows + Apache + mod_proxy

2011-11-08 Thread Omi Chiba
Paolo,

People can access the site by server name but not IP.
Do you know how to change the configuration ?

http://ochiba-183/welcome/default/index (OK)
http://10.30.6.122/welcome/default/index (NG)

On Oct 12, 1:14 pm, Paolo Caruccio  wrote:
> Well done!
>
> Paolo


Re: [web2py] Re: Determining Local Server Filepath for Uploaded Files

2011-11-08 Thread D.P. Clark
Thanks for the information Andy.

The documentation states that you can retrieve renamed file from the
'attachment' field, but I'm not sure exactly how.  I can get the pointer
(', mode 'w+b' at 0x02549440>) by using
request.args.attachment.file and also the temp filename by adding
.name--but that shows a local temp destination as opposed to the renamed
file in the 'uploads' folder.  How can I get the new name?

Any help is appreciated.

On Mon, Nov 7, 2011 at 6:51 PM, Anthony  wrote:

> When you upload a file via an upload field, by default it goes into the
> /web2py/applications/yourapp/uploads folder, though you can specify a
> different folder via the 'uploadfolder' argument to Field(). The file
> itself is renamed (for security reasons) to
> [tablename].[fieldname].[16-char-uuid].[b16encoded-original-filename].[original-extension].
> This new name is what gets stored in the upload field (the 'attachment'
> field in your case). If you want to access the file, you can retrieve the
> name from the 'attachment' field, and use that along with the path to the
> 'uploads' folder (or whatever folder you set for uploads).
>
> Note, if you do any processing of the file, there's no need to "re-insert"
> anything in the database, as the database merely stores the filename.
>
> Anthony
>
>
> On Monday, November 7, 2011 6:07:10 PM UTC-5, D.P. wrote:
>>
>> Anyone know how to pull an uploaded file from the database locally on the
>> server?  I want to do some server-side processing on the file and then
>> re-insert it to the database.  I'm not sure I understand how to get the
>> local path on the server of the uploaded file.  The static/upload directory
>> appends an random ID to the files.  How can I get the path to an uploaded
>> file so that I can manipulate it?
>>
>>
>> I'm using a standard model form like the following:
>>
>> db=DAL('sqlite://storage.db')
>> db.define_table('test',
>> Field('package_name'),
>> Field('attachment','upload',**default=''))
>>
>> My controller:
>>
>> form=SQLFORM(db.testplug)
>> if form.accepts(request.vars):
>> response.flash='Files uploaded'
>> filename = request.vars.attachment.**filename
>> filereference = request.vars.attachment.file
>> print filename
>> print filereference
>> records=SQLTABLE(db().select(**db.test.ALL),upload=download)
>> return dict(form=form,records=**records)
>>
>>
>>
>>
>>
>> My view:
>>
>> {{=records}}
>>
>> [{{=A('delete all',_href=URL('delete_**storage'))}}]
>>
>>
>>
>>


-- 
D.P.


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Massimo Di Pierro
for row in tagsummary: print row(count)

On Nov 8, 2:09 am, BrendanC  wrote:
> I'm trying to retrieve some summary data via an Ajax request with the
> following controller method.
> This is just a simple result set containing a list of tag names and usage
> counts retrieved in a JOIN query. Here's the code:
>
> def gettagsummary():
>     '''
>     Get list of tags and related counts (from tagref table) - user can then
> view by tag
>     (similar to Stack Overflow tag view??)
>     '''
>
>     count = db.tagref.tag.count()
>     tagsummary = db(db.tagref.tag==db.tag.id).select(db.tagref.tag,
> db.tag.name, count, \
>                     groupby=db.tagref.tag)
>
>     return dict(tagsummary=tagsummary)
>
> From my webpage I make an Ajax/XHR request to get this info in json format
> (the request is url: "/search/gettagsummary.json"
>
> This is what the request response  looks like:
>
> {"tagsummary": [
> {"tagref": {"tag": 1}, "tag": {"name": "Places"}, "_extra":
> {"COUNT(tagref.tag)": 4}},
>
> {"tagref": {"tag": 2}, "tag": {"name": "Cars"}, "_extra":
> {"COUNT(tagref.tag)": 2}},
> '
> .
> .
> .
> {"tagref": {"tag": 9}, "tag": {"name": "France"}, "_extra":
> {"COUNT(tagref.tag)": 2}},
> {"tagref": {"tag": 10}, "tag": {"name": "UK"}, "_extra":
> {"COUNT(tagref.tag)": 2}}
> ]}
>
> OK - so far, so good. Now I need to extract the count info in my Ajax
> response - However the count info is not easily (AFAIK) accessible - the
> '_extra' structure is a web2py artifact that looks odd. I'm thinking there
> must be a better way to pass the count info to my view (e.g. {"count":4}.
>
> So how do I change this so I can reference the count info. Do I need to
> change my controller code, or is there some (undocumented) way to reference
> the '_extra' info in the json response.
>
> I can't see anything in the docs on this - so hopefully someone here can
> point me in the right direction here.
>
> TIA,
> BrendanC


[web2py] Re: auth.settings.login_next not working on ldap authentication

2011-11-08 Thread Massimo Di Pierro
How?

On Nov 8, 7:04 am, Tito Garrido  wrote:
> Hi folks!
>
> I'm trying to redirect to a different page after login using ldap
> authentication but it just sends me to index... is it a bug?
>
> Regards,
>
> Tito
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Anthony
_extra is how web2py stores non-field values (e.g., the results of 
expressions, such as aggregate functions) within Row objects. When you 
access the item directly by subscripting the Row object, web2py 
transparently retrieves it -- that is, tagsummary[0](count) will retrieve 
the count from the first row. However, when converting to JSON, you get the 
_extra dictionary included. I'm not sure there is an easy solution other 
than to manipulate the Rows object before returning to the view. Something 
like:

ts_list = tagsummary.as_list()
for row in ts_list:
[code to pull the count out of _extra and place it elsewhere]

Anthony

On Tuesday, November 8, 2011 3:09:43 AM UTC-5, BrendanC wrote:
>
> I'm trying to retrieve some summary data via an Ajax request with the 
> following controller method.
> This is just a simple result set containing a list of tag names and usage 
> counts retrieved in a JOIN query. Here's the code:
>
> def gettagsummary():
> '''
> Get list of tags and related counts (from tagref table) - user can 
> then view by tag
> (similar to Stack Overflow tag view??) 
> '''
>
> count = db.tagref.tag.count()
> tagsummary = db(db.tagref.tag==db.tag.id).select(db.tagref.tag, 
> db.tag.name, count, \
> groupby=db.tagref.tag)
>
> return dict(tagsummary=tagsummary)
>
>
> From my webpage I make an Ajax/XHR request to get this info in json format 
> (the request is url: "/search/gettagsummary.json"
>
> This is what the request response  looks like:
>
> {"tagsummary": [
> {"tagref": {"tag": 1}, "tag": {"name": "Places"}, "_extra": 
> {"COUNT(tagref.tag)": 4}}, 
>
> {"tagref": {"tag": 2}, "tag": {"name": "Cars"}, "_extra": 
> {"COUNT(tagref.tag)": 2}}, 
> '
> .
> .
> .
> {"tagref": {"tag": 9}, "tag": {"name": "France"}, "_extra": 
> {"COUNT(tagref.tag)": 2}}, 
> {"tagref": {"tag": 10}, "tag": {"name": "UK"}, "_extra": 
> {"COUNT(tagref.tag)": 2}}
> ]}
>
> OK - so far, so good. Now I need to extract the count info in my Ajax 
> response - However the count info is not easily (AFAIK) accessible - the 
> '_extra' structure is a web2py artifact that looks odd. I'm thinking there 
> must be a better way to pass the count info to my view (e.g. {"count":4}. 
>
> So how do I change this so I can reference the count info. Do I need to 
> change my controller code, or is there some (undocumented) way to reference 
> the '_extra' info in the json response. 
>
> I can't see anything in the docs on this - so hopefully someone here can 
> point me in the right direction here. 
>
> TIA,
> BrendanC
>


[web2py] login form errors

2011-11-08 Thread Matt
Greetings,
We are currently experiencing an issue with invalid logins not showing
errors. For auth we are using a combination of basic auth and PAM, and
the actual controller/view combo for the login form is basically the
same as the generated scaffolding. When an invalid username/password
is entered the page simply reloads without any indication of what the
error was. I tried to display the flash (we are not currently using
the session flash, so this had to be added to this page) and that has
no info in it, I have also tried to display auth.login_form()'s
errors, which do not exist either. Is there some way to get this
information?

Thank you,
Matt


Re: [web2py] Re: Determining Local Server Filepath for Uploaded Files

2011-11-08 Thread Anthony
The new name is stored in the 'attachment' field of the record inserted. 
After the form.accepts, you can also access it via form.vars.attachment 
(and for backward compatibility, form.vars.attachment_newfilename).

Anthony

On Tuesday, November 8, 2011 10:33:07 AM UTC-5, D.P. wrote:
>
> Thanks for the information Andy.
>
> The documentation states that you can retrieve renamed file from the 
> 'attachment' field, but I'm not sure exactly how.  I can get the pointer 
> (', mode 'w+b' at 0x02549440>) by using 
> request.args.attachment.file and also the temp filename by adding 
> .name--but that shows a local temp destination as opposed to the renamed 
> file in the 'uploads' folder.  How can I get the new name?
>
> Any help is appreciated. 
>
> On Mon, Nov 7, 2011 at 6:51 PM, Anthony  wrote:
>
>> When you upload a file via an upload field, by default it goes into the 
>> /web2py/applications/yourapp/uploads folder, though you can specify a 
>> different folder via the 'uploadfolder' argument to Field(). The file 
>> itself is renamed (for security reasons) to 
>> [tablename].[fieldname].[16-char-uuid].[b16encoded-original-filename].[original-extension].
>>  
>> This new name is what gets stored in the upload field (the 'attachment' 
>> field in your case). If you want to access the file, you can retrieve the 
>> name from the 'attachment' field, and use that along with the path to the 
>> 'uploads' folder (or whatever folder you set for uploads).
>>
>> Note, if you do any processing of the file, there's no need to 
>> "re-insert" anything in the database, as the database merely stores the 
>> filename.
>>
>> Anthony
>>
>>
>> On Monday, November 7, 2011 6:07:10 PM UTC-5, D.P. wrote:
>>>
>>> Anyone know how to pull an uploaded file from the database locally on 
>>> the server?  I want to do some server-side processing on the file and then 
>>> re-insert it to the database.  I'm not sure I understand how to get the 
>>> local path on the server of the uploaded file.  The static/upload directory 
>>> appends an random ID to the files.  How can I get the path to an uploaded 
>>> file so that I can manipulate it?
>>>
>>>
>>> I'm using a standard model form like the following:
>>>
>>> db=DAL('sqlite://storage.db')
>>> db.define_table('test',
>>> Field('package_name'),
>>> Field('attachment','upload',**default=''))
>>>
>>> My controller:
>>>
>>> form=SQLFORM(db.testplug)
>>> if form.accepts(request.vars):
>>> response.flash='Files uploaded'
>>> filename = request.vars.attachment.**filename
>>> filereference = request.vars.attachment.file
>>> print filename
>>> print filereference
>>> records=SQLTABLE(db().select(**db.test.ALL),upload=download) 
>>> return dict(form=form,records=**records)
>>>
>>>
>>>
>>>
>>>
>>> My view:
>>>
>>> {{=records}}
>>>
>>> [{{=A('delete all',_href=URL('delete_**storage'))}}]
>>>
>>>
>>>
>>>
>
>
> -- 
> D.P.
>


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
h..
Seems that I need to return js code from controller.
btw, I have found a one-line jquery code for this-->

"$('#element_id option[value=%s]').attr('selected', 'selected');" %
dict_obj['key']

This works & I will proceed with this, for time being.
Thanks for your responses Anthony.

--- Vineet

On Nov 8, 7:31 pm, Anthony  wrote:
> I think you need .options[i] rather than .options(i). Anyway, it's
> generally easier to do this kind of thing with jQuery rather than raw
> Javascript.
>
> Anthony
>
>
>
> On Tuesday, November 8, 2011 9:04:41 AM UTC-5, Vineet wrote:
>
> > Something is wrong in the function.
> > I defined a test js function in View.
>
> > function alrt(mesg) {
> > alert(mesg) };
>
> > And in Controller,
> > return "alrt('Hello World!');"
>
> > It works.
>
> > The actual js function is---
> > (it sees which value of select box matches the one returned from
> > controller; then sets the value of select box to that value).
>
> > function selbx(elementID, value_returned_from_dataset){
> >             for (i=0;i >              {
> >                 if (value_returned_from_dataset ==
> > document.getElementById(elementID).options(i).text)
>
> > {document.getElementById(elementID).options(i).selected = true;
>
> >                      }}}
>
> > In controller---
> > return "selbx('id_of_element','%s');" % dict_obj['freq']
>
> > dict_obj['freq'] is non-blank.
> > It is a string itself.
> > 
> > If individual code-lines are returned, it works.
> > 
>
> > Any guess why so?
>
> > Regards,
> > Vineet
>
> > On Nov 8, 6:44 pm, Anthony  wrote:
> > > On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote:
>
> > > > > If 'myvar' is a Python variable, you're going
>
> > > > 'myvar' is a not a python variable.
> > > > I pass the id of html element as argument.
> > > > Javascript code sets the value of that html element.
>
> > > OK, but same problem -- 'myvar1' isn't a javascript variable either --
> > it
> > > is a string identifying an html element. So you would still have to
> > return
> > > 'abc("myvar1")', or maybe 'abc("#myvar1")', depending on how you are
> > using
> > > it in the code.
>
> > > Anthony


Re: [web2py] Re: auth.settings.login_next not working on ldap authentication

2011-11-08 Thread Tito Garrido
Not sure Why but it just doesn't happen anything:

from gluon.contrib.login_methods.ldap_auth import ldap_auth
auth.settings.login_methods=[ldap_auth(mode='company',server='mycompany.com
',base_dn='ou=myou,o=mycompany.com')]
auth.settings.actions_disabled=['register','change_password','request_reset_password','profile']
auth.settings.remember_me_form = False
auth.settings.login_next = URL('default','get_mygroups')

Can't see nothing wrong...

On Tue, Nov 8, 2011 at 1:46 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> How?
>
> On Nov 8, 7:04 am, Tito Garrido  wrote:
> > Hi folks!
> >
> > I'm trying to redirect to a different page after login using ldap
> > authentication but it just sends me to index... is it a bug?
> >
> > Regards,
> >
> > Tito
> >
> > --
> >
> > Linux User #387870
> > .
> >  _/_õ|__|
> > ..º[ .-.___.-._| . . . .
> > .__( o)__( o).:___
>



-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___


[web2py] Re: ajax function with eval : return js function from controller

2011-11-08 Thread Vineet
h..
Seems that I need to return js code lines (not js function) from
controller & get going ahead.
btw, I have found one line jquery code for selecting value of select
box.

"$('#element_id option[value=%s]').attr('selected', 'selected');" %
adict['key']

Thanks for your responses Anthony.

--- Vineet

On Nov 8, 7:31 pm, Anthony  wrote:
> I think you need .options[i] rather than .options(i). Anyway, it's
> generally easier to do this kind of thing with jQuery rather than raw
> Javascript.
>
> Anthony
>
>
>
> On Tuesday, November 8, 2011 9:04:41 AM UTC-5, Vineet wrote:
>
> > Something is wrong in the function.
> > I defined a test js function in View.
>
> > function alrt(mesg) {
> > alert(mesg) };
>
> > And in Controller,
> > return "alrt('Hello World!');"
>
> > It works.
>
> > The actual js function is---
> > (it sees which value of select box matches the one returned from
> > controller; then sets the value of select box to that value).
>
> > function selbx(elementID, value_returned_from_dataset){
> >             for (i=0;i >              {
> >                 if (value_returned_from_dataset ==
> > document.getElementById(elementID).options(i).text)
>
> > {document.getElementById(elementID).options(i).selected = true;
>
> >                      }}}
>
> > In controller---
> > return "selbx('id_of_element','%s');" % dict_obj['freq']
>
> > dict_obj['freq'] is non-blank.
> > It is a string itself.
> > 
> > If individual code-lines are returned, it works.
> > 
>
> > Any guess why so?
>
> > Regards,
> > Vineet
>
> > On Nov 8, 6:44 pm, Anthony  wrote:
> > > On Tuesday, November 8, 2011 8:17:41 AM UTC-5, Vineet wrote:
>
> > > > > If 'myvar' is a Python variable, you're going
>
> > > > 'myvar' is a not a python variable.
> > > > I pass the id of html element as argument.
> > > > Javascript code sets the value of that html element.
>
> > > OK, but same problem -- 'myvar1' isn't a javascript variable either --
> > it
> > > is a string identifying an html element. So you would still have to
> > return
> > > 'abc("myvar1")', or maybe 'abc("#myvar1")', depending on how you are
> > using
> > > it in the code.
>
> > > Anthony- Hide quoted text -
>
> - Show quoted text -


[web2py] configuration of mail in appengine

2011-11-08 Thread Rohitraj Sharma
i want to configure the mail in google appengine. i try in smtp server
gae , but its not work.


[web2py] access control(RBAC)

2011-11-08 Thread Rohitraj Sharma
i have so many group, i want according to group user can access the
data. For example  admin have all controls of CURD,normal user can
view data , manager van view and edit, some other user can view only
few tabs of menu.Please help me i am able to do . i have more then 50
tabs, tab have also show according to user. admin can see all tab.
other user depending on rool .


Re: [web2py] Re: new web site

2011-11-08 Thread JmiXIII
Looks great,
Nevertheless

http://web2py.com/new_examples/default/what
After The best way
=> too much to read and to compact, a more visual,structured presentation 
would be easier to read


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread BrendanC
@Massimo - your response assumes the data is being consumed in python, not 
in a json response which is where it gets ugly - see the code below. 

@Anthony,
per your suggestion I think the data needs some additional  processing 
 before returning a response - in which case why not skip the dal and use 
an exec sql command. 

For completeness  here is how I coded the reference to the computed value 
 in my Javascript - imho this is a truly ugly hack, since the view is now 
tightly coupled to the way the web2py dal  handles computed fields, when it 
should be treated as just another data element. (Not sure I'd want to 
maintain this type of code).

// display the json response
//
  var itags = response.tagsummary; 
for (var x=0; x< itags.length; x++){
dojo.byId("tagsummary").innerHTML += '' + itags[x].tag.name 
+'; '  + itags[x]._extra['COUNT(tagref.tag)' ]+ '';
}

BrendanC


Re: [web2py] Re: Determining Local Server Filepath for Uploaded Files

2011-11-08 Thread D.P. Clark
Thanks Anthony.  It's all working as expected now.

My confusion was between calling the filename through form and calling it
through db.

On Tue, Nov 8, 2011 at 11:33 AM, Anthony  wrote:

> The new name is stored in the 'attachment' field of the record inserted.
> After the form.accepts, you can also access it via form.vars.attachment
> (and for backward compatibility, form.vars.attachment_newfilename).
>
> Anthony
>
>
> On Tuesday, November 8, 2011 10:33:07 AM UTC-5, D.P. wrote:
>
>> Thanks for the information Andy.
>>
>> The documentation states that you can retrieve renamed file from the
>> 'attachment' field, but I'm not sure exactly how.  I can get the pointer
>> (', mode 'w+b' at 0x02549440>) by using
>> request.args.attachment.file and also the temp filename by adding
>> .name--but that shows a local temp destination as opposed to the renamed
>> file in the 'uploads' folder.  How can I get the new name?
>>
>> Any help is appreciated.
>>
>> On Mon, Nov 7, 2011 at 6:51 PM, Anthony  wrote:
>>
>>> When you upload a file via an upload field, by default it goes into the
>>> /web2py/applications/yourapp/**uploads folder, though you can specify a
>>> different folder via the 'uploadfolder' argument to Field(). The file
>>> itself is renamed (for security reasons) to [tablename].[fieldname].[16-
>>> **char-uuid].[b16encoded-**original-filename].[original-**extension].
>>> This new name is what gets stored in the upload field (the 'attachment'
>>> field in your case). If you want to access the file, you can retrieve the
>>> name from the 'attachment' field, and use that along with the path to the
>>> 'uploads' folder (or whatever folder you set for uploads).
>>>
>>> Note, if you do any processing of the file, there's no need to
>>> "re-insert" anything in the database, as the database merely stores the
>>> filename.
>>>
>>> Anthony
>>>
>>>
>>> On Monday, November 7, 2011 6:07:10 PM UTC-5, D.P. wrote:

 Anyone know how to pull an uploaded file from the database locally on
 the server?  I want to do some server-side processing on the file and then
 re-insert it to the database.  I'm not sure I understand how to get the
 local path on the server of the uploaded file.  The static/upload directory
 appends an random ID to the files.  How can I get the path to an uploaded
 file so that I can manipulate it?


 I'm using a standard model form like the following:

 db=DAL('sqlite://storage.db')
 db.define_table('test',
 Field('package_name'),
 Field('attachment','upload',**de**fault=''))

 My controller:

 form=SQLFORM(db.testplug)
 if form.accepts(request.vars):
 response.flash='Files uploaded'
 filename = request.vars.attachment.**filena**me
 filereference = request.vars.attachment.file
 print filename
 print filereference
 records=SQLTABLE(db().select(**d**b.test.ALL),upload=download)
 return dict(form=form,records=**records**)





 My view:

 {{=records}}

 [{{=A('delete all',_href=URL('delete_**storage**'))}}]




>>
>>
>> --
>> D.P.
>>
>


-- 
D.P.


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 1:01:08 PM UTC-5, BrendanC wrote:
>
> @Massimo - your response assumes the data is being consumed in python, not 
> in a json response which is where it gets ugly - see the code below. 
>
> @Anthony,
> per your suggestion I think the data needs some additional  processing 
>  before returning a response - in which case why not skip the dal and use 
> an exec sql command.
>

Yes, that would be another alternative.
 

> For completeness  here is how I coded the reference to the computed value 
>  in my Javascript - imho this is a truly ugly hack, since the view is now 
> tightly coupled to the way the web2py dal  handles computed fields, when it 
> should be treated as just another data element. (Not sure I'd want to 
> maintain this type of code).
>

I wouldn't do it client side -- I'd straighten out the data server side (as 
per my suggestion or via executesql). Longer term, maybe we can do 
something with the Rows.as_list() method that produces more usable output 
when the Rows object is the result of a join and/or includes the output of 
expressions (i.e., '_extra').

Anthony



Re: [web2py] Re: Virtual Fields and usual database's Views

2011-11-08 Thread BrendanC
The problem with using a view is that Web2py/Django/Rails is that they all 
expect a unique id field in the result set. If you create your views with a 
dummy id field you may be able to use it as a 'pseudo' table. However you 
still need to somehow populate that field with a unique value.  Also 
understand that you cannot update the view - which you probably don't want 
to do anyway.

BrendanC





[web2py] help with complex model creation

2011-11-08 Thread demetrio
Hi everyone,

i'm starting a new project with web2py, and now i'm defining the model
of the app and i have some questions.

the "classical" and simplified model (there are lots of tables but the
questions are about those)  is something like:

Table 'companies'
  - id_company
  - name
  - 

Table 'guild'
  - id_guild
  - name
  - 

Table 'construction' (i don't really know if "construction" is the
correct english word for this example, or maybe "building_lot")
  - id_construction
  - name
  - 

And now I have to make the relations. In this case one companies can
have many guilds (i.e: the company 'company1' owns to the 'painters'
guild and the 'doors' guild). This relation would be easy in web2py
with a list:reference.

But the case is that in a building lot, can have one company working
with an specific guild, and in other building lot, the same company
working with another guild.

For example:
   In the construction "A" of 5 apartments, the company "company1"
only works installing windows.
   In the construction "B" of 20 apartments, the company "company1"
only works painting the walls.

In a classic table_has_table model, I could have this:

Table "company_has_guild":
  - id_company_has_guild
  - id_company
  - id_guild

And:

Table "construction_has_company_has_guild" (and at this moment don't
know if this is the best way to make this relation...)
  - id_construction
  - id_company_has_guild

As I have mentioned before, the first relation (company_has_guilds)
with web2py would be easy:

db.define_table("guilds",
   Field("name", "string")
   )

db.define_table("company",
   Field("name", "string"),
   Field("guilds", "list:reference guilds")
   )

Any suggestions about the creation of the second relation
(construction_has_company_has_guild)? Or I have to create the
"classic" table_has_table model? In this case, there is some efficient
way to make it in web2py?

Thanks in advance!
Daniel


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread BrendanC
Anthony,
Thx for your feedback - I agree that this should be handlled on the server 
- I just wanted to illustrate how ugly the response processing becomes 
using the default features of web2py. 

BTW/Off topic - Web2py is great and the user community/support is active. 

However as someone just diving into web2py I think that one area for 
improvement is in the documentation - especially in the examples. Some of 
it feels like I'm reading an API with little in the way of sample usage - 
given time I can/will probably figure it out, but it takes additional time 
and moves my focus away from the task at hand.   A lot of the docs are 
good, but many of the examples (e.g. in the DAL section) are very cryptic 
and don't have much in the way of annotation re usage tips and constraints. 

As an experienced SQL/database developer I'd find it helpful to show some 
SQL examples and the DAL equivalent. In the case of computed columns it 
took me a while to understand the use of the '_extra' construct.  When I 
get it working I'll post my coding solution to my view problem - however I 
think this is the kind of detail I'd expect to see in the docs.

This is not a gripe/complaint - just sharing this with you as I know you 
are active on this forum and feedback on specific issues may be helpful to 
others in the future.

BrendanC



[web2py] Re: Windows + Apache + mod_proxy

2011-11-08 Thread Paolo Caruccio
Omi,

please try the following:

in vhost_web2py.conf replace
 

ServerName ochiba-183

with

ServerName ochiba-183

where LIP is the server's IP

See for reference my previous post (STEP D)

Let me know if it works.

Paolo

P.S. Moreover what do you think about to change the thread title  to Windows 
+ Apache + mod_wsgi ?

 


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 1:42:25 PM UTC-5, BrendanC wrote:
>
> In the case of computed columns it took me a while to understand the use 
> of the '_extra' construct.
>

I agree. I'm working on better documentation of the use of expressions in 
general, and in selects (i.e., computed columns) in particular. Note, 
_extra is an implementation detail and not part of the API, so not promised 
to remain backward compatible. It is not needed when directly accessing 
data from Row objects, but as you have discovered, there are issues when 
converting to formats like JSON.

Anthony


[web2py] Re: Windows + Apache + mod_proxy

2011-11-08 Thread Omi Chiba
It worked !!
Thanks again!

On Nov 8, 12:43 pm, Paolo Caruccio  wrote:
> Omi,
>
> please try the following:
>
> in vhost_web2py.conf replace
>
> 
> ServerName ochiba-183
>
> with
> 
> ServerName ochiba-183
>
> where LIP is the server's IP
>
> See for reference my previous post (STEP D)
>
> Let me know if it works.
>
> Paolo
>
> P.S. Moreover what do you think about to change the thread title  to Windows
> + Apache + mod_wsgi ?


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread BrendanC
>>
as you have discovered, there are issues when converting to formats like 
JSON.
>>
Agreed - In an 'Ajaxy'  web world it it important to 'play nice'  with 
things like json and making this clean this should not be an afterthought. 
 (FWIW/BTW If I were comparing frameworks for serious Web development (I'm 
not) this sort of wart would likely steer me away from the framework as I 
would expect heavy ajax/json usage on any interactive website). 

My concern is not that there is no workaround - it's more that no one seems 
to have foreseen and/or documented potential issues re the using json and 
computed results. After 4/5 years of development I can't be the first 
person to deal with this issue. (Massimo's earlier response indicates (to 
me) that he is clearly thinking server side, but perhaps has not fully 
considered the end to end solution).

>From a practical standpoint maybe some beefing up of the json section of 
the docs would be helpful. Right now I'm building a small demo app using 
dojo, ajax and web2py - I'll be happy to share any useful code samples when 
I'm a bit further on with my project. 

BrendanC

   
   



[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 2:18:59 PM UTC-5, BrendanC wrote:
>
> After 4/5 years of development I can't be the first person to deal with 
> this issue.
>

Perhaps, but it's the first time I've seen it come up. 


Re: [web2py] Re: Online Book Typo

2011-11-08 Thread Ismael Serratos
another :p

and it is used internally by the *SQLFORM.gird *and SQLFORM.smartgrid.

Should be SQLFORM.grid instead of SQLFORM.gird

in http://web2py.com/book/default/chapter/06#smart_query-%28experimental%29

On Mon, Nov 7, 2011 at 5:54 PM, Anthony  wrote:

> FYI, I am not specifically looking for typos, but I am adding a bunch of
> material to the book and reviewing most of the newer material, so I'm
> catching a lot of typos and errors as well. So, as Andrew says, most of the
> typos and formatting issues will likely be resolved by the next release.
>
> Anthony
>
>
> On Monday, November 7, 2011 5:54:37 PM UTC-5, Andrew wrote:
>
>> I'm going through the book in detail looking for typos, and trying to
>> absorb some more learnings at the same time.  By all means go ahead,
>> but we may be doubling up in effort.  May I suggest waiting for a
>> cleaned up Version 3.3 ?  I hope it will only contain one or two
>> missed typos that may need many eyes to find.
>>
>> Regards
>> Andrew
>>
>> P.S.  You did find one in a chapter that I had already reviewed :)
>>
>>
>> On Nov 8, 10:44 am, mikech  wrote:
>> > Ok I'm reading thru that chapter, and forward.  So I'll report what I
>> find.
>>
>


[web2py] Re: help with complex model creation

2011-11-08 Thread Yannick
Hello,
Im not sure if I fully understand your example but I believe that the
relation:
"Contruction and Company" is a many to many relationship so you just
need to have a third table in the middle

Construction <---> Reference <> Company
and Reference is a third table that keep track of the company ID and
Contruction ID

I hope it helps.

Cheers,

On Nov 8, 1:18 pm, demetrio  wrote:
> Hi everyone,
>
> i'm starting a new project with web2py, and now i'm defining the model
> of the app and i have some questions.
>
> the "classical" and simplified model (there are lots of tables but the
> questions are about those)  is something like:
>
> Table 'companies'
>   - id_company
>   - name
>   - 
>
> Table 'guild'
>   - id_guild
>   - name
>   - 
>
> Table 'construction' (i don't really know if "construction" is the
> correct english word for this example, or maybe "building_lot")
>   - id_construction
>   - name
>   - 
>
> And now I have to make the relations. In this case one companies can
> have many guilds (i.e: the company 'company1' owns to the 'painters'
> guild and the 'doors' guild). This relation would be easy in web2py
> with a list:reference.
>
> But the case is that in a building lot, can have one company working
> with an specific guild, and in other building lot, the same company
> working with another guild.
>
> For example:
>    In the construction "A" of 5 apartments, the company "company1"
> only works installing windows.
>    In the construction "B" of 20 apartments, the company "company1"
> only works painting the walls.
>
> In a classic table_has_table model, I could have this:
>
> Table "company_has_guild":
>   - id_company_has_guild
>   - id_company
>   - id_guild
>
> And:
>
> Table "construction_has_company_has_guild" (and at this moment don't
> know if this is the best way to make this relation...)
>   - id_construction
>   - id_company_has_guild
>
> As I have mentioned before, the first relation (company_has_guilds)
> with web2py would be easy:
>
> db.define_table("guilds",
>    Field("name", "string")
>    )
>
> db.define_table("company",
>    Field("name", "string"),
>    Field("guilds", "list:reference guilds")
>    )
>
> Any suggestions about the creation of the second relation
> (construction_has_company_has_guild)? Or I have to create the
> "classic" table_has_table model? In this case, there is some efficient
> way to make it in web2py?
>
> Thanks in advance!
> Daniel


Re: [web2py] help with complex model creation

2011-11-08 Thread Richard Vézina
Hello Daniel,

I suggest you to normalized your schema before using feature like
list:reference that impose denormalisation to work... If your model is only
a bit complexe you will be rapidly always making trade off between ease of
implementation of interface with web2py feature and good design
practices... Web2py allow ease prototyping that pretty nice if you follow
the concept of one table - one form, but you have to build your own complex
controllers functions for complex schema to follow good design practices
don't fall into the pit of rapid gain at interface level because you will
pay the price later for sure... You will have to refactor your model and
your app and migrate data into new schema... That one side...


The other side...
Agile tell that you should rapidly prototyping system that respond to the
need before any thing else and web2py allow you to develop really fast...
So... You maybe have to keep in mind that you will have to refactor to
respond you client need rapidly. The problem you will face is that your
client will start to ask questions when, because of refactoring, you will
tell him that new feature will take a lot more time...

For sure many to many relation need custom form build with SQLFORM.factory
or helpers... Also if you want SQLFORM.factory to work pay attention to the
name of your primary key (don't use the same name for pk and fk) and
duplicate field name in the differents tables you have because _filter_fields
function will fail...

Hope it helps.

Richard

On Tue, Nov 8, 2011 at 1:18 PM, demetrio  wrote:

> Hi everyone,
>
> i'm starting a new project with web2py, and now i'm defining the model
> of the app and i have some questions.
>
> the "classical" and simplified model (there are lots of tables but the
> questions are about those)  is something like:
>
> Table 'companies'
>  - id_company
>  - name
>  - 
>
> Table 'guild'
>  - id_guild
>  - name
>  - 
>
> Table 'construction' (i don't really know if "construction" is the
> correct english word for this example, or maybe "building_lot")
>  - id_construction
>  - name
>  - 
>
> And now I have to make the relations. In this case one companies can
> have many guilds (i.e: the company 'company1' owns to the 'painters'
> guild and the 'doors' guild). This relation would be easy in web2py
> with a list:reference.
>
> But the case is that in a building lot, can have one company working
> with an specific guild, and in other building lot, the same company
> working with another guild.
>
> For example:
>   In the construction "A" of 5 apartments, the company "company1"
> only works installing windows.
>   In the construction "B" of 20 apartments, the company "company1"
> only works painting the walls.
>
> In a classic table_has_table model, I could have this:
>
> Table "company_has_guild":
>  - id_company_has_guild
>  - id_company
>  - id_guild
>
> And:
>
> Table "construction_has_company_has_guild" (and at this moment don't
> know if this is the best way to make this relation...)
>  - id_construction
>  - id_company_has_guild
>
> As I have mentioned before, the first relation (company_has_guilds)
> with web2py would be easy:
>
> db.define_table("guilds",
>   Field("name", "string")
>   )
>
> db.define_table("company",
>   Field("name", "string"),
>   Field("guilds", "list:reference guilds")
>   )
>
> Any suggestions about the creation of the second relation
> (construction_has_company_has_guild)? Or I have to create the
> "classic" table_has_table model? In this case, there is some efficient
> way to make it in web2py?
>
> Thanks in advance!
> Daniel


Re: [web2py] help with complex model creation

2011-11-08 Thread Richard Vézina
Forgot this link :
http://web2py.com/book/default/chapter/07#One-form-for-multiple-tables

On Tue, Nov 8, 2011 at 4:04 PM, Richard Vézina
wrote:

> Hello Daniel,
>
> I suggest you to normalized your schema before using feature like
> list:reference that impose denormalisation to work... If your model is only
> a bit complexe you will be rapidly always making trade off between ease of
> implementation of interface with web2py feature and good design
> practices... Web2py allow ease prototyping that pretty nice if you follow
> the concept of one table - one form, but you have to build your own complex
> controllers functions for complex schema to follow good design practices
> don't fall into the pit of rapid gain at interface level because you will
> pay the price later for sure... You will have to refactor your model and
> your app and migrate data into new schema... That one side...
>
>
> The other side...
> Agile tell that you should rapidly prototyping system that respond to the
> need before any thing else and web2py allow you to develop really fast...
> So... You maybe have to keep in mind that you will have to refactor to
> respond you client need rapidly. The problem you will face is that your
> client will start to ask questions when, because of refactoring, you will
> tell him that new feature will take a lot more time...
>
> For sure many to many relation need custom form build with SQLFORM.factory
> or helpers... Also if you want SQLFORM.factory to work pay attention to the
> name of your primary key (don't use the same name for pk and fk) and
> duplicate field name in the differents tables you have because _filter_fields
> function will fail...
>
> Hope it helps.
>
> Richard
>
> On Tue, Nov 8, 2011 at 1:18 PM, demetrio  wrote:
>
>> Hi everyone,
>>
>> i'm starting a new project with web2py, and now i'm defining the model
>> of the app and i have some questions.
>>
>> the "classical" and simplified model (there are lots of tables but the
>> questions are about those)  is something like:
>>
>> Table 'companies'
>>  - id_company
>>  - name
>>  - 
>>
>> Table 'guild'
>>  - id_guild
>>  - name
>>  - 
>>
>> Table 'construction' (i don't really know if "construction" is the
>> correct english word for this example, or maybe "building_lot")
>>  - id_construction
>>  - name
>>  - 
>>
>> And now I have to make the relations. In this case one companies can
>> have many guilds (i.e: the company 'company1' owns to the 'painters'
>> guild and the 'doors' guild). This relation would be easy in web2py
>> with a list:reference.
>>
>> But the case is that in a building lot, can have one company working
>> with an specific guild, and in other building lot, the same company
>> working with another guild.
>>
>> For example:
>>   In the construction "A" of 5 apartments, the company "company1"
>> only works installing windows.
>>   In the construction "B" of 20 apartments, the company "company1"
>> only works painting the walls.
>>
>> In a classic table_has_table model, I could have this:
>>
>> Table "company_has_guild":
>>  - id_company_has_guild
>>  - id_company
>>  - id_guild
>>
>> And:
>>
>> Table "construction_has_company_has_guild" (and at this moment don't
>> know if this is the best way to make this relation...)
>>  - id_construction
>>  - id_company_has_guild
>>
>> As I have mentioned before, the first relation (company_has_guilds)
>> with web2py would be easy:
>>
>> db.define_table("guilds",
>>   Field("name", "string")
>>   )
>>
>> db.define_table("company",
>>   Field("name", "string"),
>>   Field("guilds", "list:reference guilds")
>>   )
>>
>> Any suggestions about the creation of the second relation
>> (construction_has_company_has_guild)? Or I have to create the
>> "classic" table_has_table model? In this case, there is some efficient
>> way to make it in web2py?
>>
>> Thanks in advance!
>> Daniel
>
>
>


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Zphen
Ive got to say that this is an annoyance for me too.

I've been working around it to date but been thinking of delving into
the world of the JSON serializer to see how hard it would be to make
the _extra fields come through properly.

Problem is that DAL would also have to be touched to provide the
equivalent of SQL AS so that something else than the expression can be
returned as the column name.



On Nov 9, 6:35 am, Anthony  wrote:
> On Tuesday, November 8, 2011 2:18:59 PM UTC-5, BrendanC wrote:
>
> > After 4/5 years of development I can't be the first person to deal with
> > this issue.
>
> Perhaps, but it's the first time I've seen it come up.


[web2py] Re: login form errors

2011-11-08 Thread Yannick
Not sure if I understand your issue. Have you set up the session.flash
in your controller and the value of it is not showing off ?  Are you
doing a redirect when the login failed ?

Maybe if you show us a sample of your code we may have a better
understanding of your issue.

Cheers,

On Nov 8, 11:14 am, Matt  wrote:
> Greetings,
> We are currently experiencing an issue with invalid logins not showing
> errors. For auth we are using a combination of basic auth and PAM, and
> the actual controller/view combo for the login form is basically the
> same as the generated scaffolding. When an invalid username/password
> is entered the page simply reloads without any indication of what the
> error was. I tried to display the flash (we are not currently using
> the session flash, so this had to be added to this page) and that has
> no info in it, I have also tried to display auth.login_form()'s
> errors, which do not exist either. Is there some way to get this
> information?
>
> Thank you,
> Matt


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 4:20:32 PM UTC-5, Zphen wrote:
>
> I've been working around it to date but been thinking of delving into 
> the world of the JSON serializer to see how hard it would be to make 
> the _extra fields come through properly.
>

web2py's custom JSON serializer first calls the Rows.as_list() method (or 
the Row.as_dict()) method, so it would be better to alter the as_list() and 
as_dict() methods so the results will be useful for more than just JSON.
 

> Problem is that DAL would also have to be touched to provide the 
> equivalent of SQL AS so that something else than the expression can be 
> returned as the column name.
>

Yes, that would be useful as well, independent of the JSON issue.

Anthony


[web2py] Re: help with complex model creation

2011-11-08 Thread Cliff

db.define_table("company",
   Field("name", "string"),
   Field("guilds", db.guilds)
   )

Also, see IS_NOT_IN_DB and IS_IN_DB in the online book,
http://www.web2py.com/book/default/chapter/07

On Nov 8, 1:18 pm, demetrio  wrote:
> Hi everyone,
>
> i'm starting a new project with web2py, and now i'm defining the model
> of the app and i have some questions.
>
> the "classical" and simplified model (there are lots of tables but the
> questions are about those)  is something like:
>
> Table 'companies'
>   - id_company
>   - name
>   - 
>
> Table 'guild'
>   - id_guild
>   - name
>   - 
>
> Table 'construction' (i don't really know if "construction" is the
> correct english word for this example, or maybe "building_lot")
>   - id_construction
>   - name
>   - 
>
> And now I have to make the relations. In this case one companies can
> have many guilds (i.e: the company 'company1' owns to the 'painters'
> guild and the 'doors' guild). This relation would be easy in web2py
> with a list:reference.
>
> But the case is that in a building lot, can have one company working
> with an specific guild, and in other building lot, the same company
> working with another guild.
>
> For example:
>    In the construction "A" of 5 apartments, the company "company1"
> only works installing windows.
>    In the construction "B" of 20 apartments, the company "company1"
> only works painting the walls.
>
> In a classic table_has_table model, I could have this:
>
> Table "company_has_guild":
>   - id_company_has_guild
>   - id_company
>   - id_guild
>
> And:
>
> Table "construction_has_company_has_guild" (and at this moment don't
> know if this is the best way to make this relation...)
>   - id_construction
>   - id_company_has_guild
>
> As I have mentioned before, the first relation (company_has_guilds)
> with web2py would be easy:
>
> db.define_table("guilds",
>    Field("name", "string")
>    )
>
> db.define_table("company",
>    Field("name", "string"),
>    Field("guilds", "list:reference guilds")
>    )
>
> Any suggestions about the creation of the second relation
> (construction_has_company_has_guild)? Or I have to create the
> "classic" table_has_table model? In this case, there is some efficient
> way to make it in web2py?
>
> Thanks in advance!
> Daniel


[web2py] Re: login form errors

2011-11-08 Thread Cliff
Is there a div with the id of 'flash' in your view?

On Nov 8, 11:14 am, Matt  wrote:
> Greetings,
> We are currently experiencing an issue with invalid logins not showing
> errors. For auth we are using a combination of basic auth and PAM, and
> the actual controller/view combo for the login form is basically the
> same as the generated scaffolding. When an invalid username/password
> is entered the page simply reloads without any indication of what the
> error was. I tried to display the flash (we are not currently using
> the session flash, so this had to be added to this page) and that has
> no info in it, I have also tried to display auth.login_form()'s
> errors, which do not exist either. Is there some way to get this
> information?
>
> Thank you,
> Matt


[web2py] Re: SQLFORM.grid and query

2011-11-08 Thread Cliff
What is this code supposed to do?

records=db(query).select()
for record in records:
Ct=Ct+record.CtReb
if selection.accepts(request.vars,keepvalues=True):
pass

On Nov 8, 8:02 am, JmiXIII  wrote:
> Hello,
>
> I have something like:
>
>     selection=FORM(TABLE(TR(
>                 TD('Début',INPUT(_name='Deb'),
> _class="date", requires = IS_DATE(error_message=T('Doit être de la forme
> -MM-JJ !'))),
>                 TD('Fin',INPUT(_name='Fin',_class="date", requires =
> IS_DATE(error_message=T('Doit être de la forme -MM-JJ !',
>
> TD('Famille',SELECT('Frappe','Reprise','Tri',_name='Famille')),
>                 TD(INPUT(_type='submit',_value='Sélectionner'))
>                 )))
>     Deb=request.vars.Deb
>     Fin=request.vars.Fin
>     Famille=request.vars.Famille
>     Ct=0
>     query1=db.Rebuts.Date>=Deb
>     query2=db.Rebuts.Date<=Fin
>     query3=db.Rebuts.Famille==Famille
>     if Famille=='Tri' :
> query3=(db.Rebuts.Machine=='TRI')&(db.Rebuts.Famille=='NQ')
>     if Famille=='Reprise' :
> query3=(db.Rebuts.Famille!='NQ')&(db.Rebuts.Famille!='Frappe')
>     query=query1&query2&query3
>     records=db(query).select()
>     for record in records:
>         Ct=Ct+record.CtReb
>     if selection.accepts(request.vars,keepvalues=True):
>         pass
>     form=SQLFORM.grid(query)
>     return dict(selection=selection,Ct=Ct,form=form
>
> Everything is all right except, I can't paginate with sqlform.grid
> (selection form data seems to be lost).
> Can somebody give a way to solve it ?
> Thanks in advance


[web2py] Json, Ajax, Inner Join , Group By and '_extra' revisited - code example included

2011-11-08 Thread BrendanC
OK - I posted earlier on this thread  
https://groups.google.com/forum/#!topic/web2py/8yypDdtmG9g and vented some 
frustration re the handling of computed columns. Rather than clutter up the 
old threat I'm creating a new thread that contains the code that solves my 
problem.
Feel free to offer alternative and/or more general alternatives - my code 
is very case specific.  

I reworked my controller method ('gettagcounts' to avoid any references to 
backwardly incompatible references such as  '_extra'. The following code is 
what I came up with. I have included some copious comments here to help 
anyone who runs into this in the future. 

(FWIW - So far I have found the Web2py examples too cryptic with no 
guidelines for usage and constraints - they seem to assume that you already 
know Web2py and it's hard to find specific examples  - this can be 
frustrating and time consuming for those just testing the web2py waters).

On with the code!

def gettagcounts():
'''
DAL Example Combining Inner Join Query and a computed column.
The use case here is:
  -  find the tag values and related counts for a set of blog posts
  -  return custom result set containing id, name and count

This example shows how to construct a user friendly response that
avoids any references to the DAL's '_extra' artifacts

The expected Json result has this format:

{"tagsummary": [
{"count": 4, "name": "Places", "id": 1}, 
{"count": 2, "name": "Cars", "id": 2}, 
{"count": 2, "name": "Boats", "id": 3}
]}

'''

# Construct the required DAL objects
# Note that the count will be 'lazy loaded' when the query is executed
count = db.tagref.tag.count()

# the following DAL statement ressolves to an inner join sql query
# Note that I am *NOT* using the 'as_select()' method here
# 
tagsummary = db(db.tagref.tag==db.tag.id).select(db.tagref.tag, 
db.tag.name, count, \
groupby=db.tagref.tag)

#
#BTW - Here's the generated SQL string - you could just exec this as
#a SQL statement w/out using the DAL
#   'SELECT  tagref.tag, tag.name, COUNT(tagref.tag) FROM tagref, tag 
#WHERE (tagref.tag = tag.id) GROUP BY tagref.tag;'
#

# create an array for a custom list of dicts 
# containing the required columns 
# note the syntax for the computed 'count' field
# In the DAL computed fields are handled separately from table fields

tlist = []
for item in tagsummary:
d = {}
d['count'] = item[count]# <-- note the syntax
d['name'] = item.tag.name
d['id'] = item.tagref.tag
tlist.append(d)

# return custom results for consumptionj by the view
return dict(tagsummary=tlist)

# Finally - in case anyone is interested here is the json response 
populated 
# with some test data - nice and easy to handle on the client side.
# No hidden '_extras' included .







[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread BrendanC
FWIW - I just create a new posting with some code that addresses the issues 
mentioned here.  

Here's the link: https://groups.google.com/forum/#!topic/web2py/CEHLCbMCPw0

Over and Out
BrendanC




[web2py] Re: web2py with SAE Python

2011-11-08 Thread chinakr
With the hint from SAE Python maintainer, I use __file__ to solve the
path problem.

$ pwd
~/src/web2py_sae/3
$ gvim config.py &
import os
app_root = os.path.dirname(__file__)
$ gvim gluon/main.py &
from config import app_root
version_path = os.path.join(app_root, 'VERSION')
version_info = open(version_path)

Now the problem is still the 'invalid request' without python error.
How can I find the log?
http://web2py.sinaapp.com/welcome/default/index
http://web2py.sinaapp.com/debug

thx!

On Nov 8, 10:53 pm, chinakr  wrote:
> My new index.wsgi is as follow:
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> import sae
>
> from gluon.settings import global_settings
> global_settings.web2py_runtime_gae = True
>
> import gluon.main
>
> app = gluon.main.wsgibase
> application = sae.create_wsgi_app(app)
> #application = app
>
> And I also have to disable open function in gluon/main.py:
>
> #version_info = open(abspath('VERSION', gluon=True), 'r')
> #version_info = open('../VERSION')
> version_info = 'Version 1.99.2 (2011-09-26 06:55:33) stable'
> #web2py_version = parse_version(version_info.read().strip())
> web2py_version = parse_version(version_info)
> #version_info.close()
> global_settings.web2py_version = web2py_version
>
> Now the error is still 'invalid 
> request':http://web2py.sinaapp.com/welcome/default/indexhttp://web2py.sinaapp.com/debug
>
> What should I do know?
>
> On Nov 7, 10:30 pm, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > Try this:
>
> > import sae
> > import gluon.main
> > from gluon.settings import global_settings
> > global_settings.web2py_runtime_gae = True
> > application = gluon.main.wsgibase
>
> > On Nov 7, 1:57 am, chinakr  wrote:
>
> > > SAE means Sina App Engine, which is a public cloud computing platform
> > > like GAE. It's the most mature and famous public cloud in China, where
> > > people can't access GAE freely. SAE only supports PHP in the last 3
> > > years.
>
> > > Recently, SAE started internal testing with Python support, with code
> > > name SAE Python.
>
> > > I would like to deploy web2py on SAE Python. And as GAE, SAE Python
> > > doesn't provide local file I/O, etc. I have to modify a lot of things
> > > manually.
>
> > > As lack of experience and time, it seems a hard task for me. So anyone
> > > can help?
>
> > >http://3.web2py.sinaapp.com/welcome/default/index
> > > will get 'invalid request' message with following index.wsgi:
>
> > > import sae
> > > import gluon.main
>
> > > app = gluon.main.wsgibase
> > > application = sae.create_wsgi_app(app)
>
> > > I also comment mkdir and open code in main.py.
>
> > > SAE Python 
> > > documents:http://appstack.sinaapp.com/static/doc/release/testing/index.html


Re: [web2py] Re: A SQLFORM.grid question

2011-11-08 Thread Mike Veltman


I am wondering about that. mmm

On 11/03/2011 10:53 PM, apple wrote:

My mistake. I tend to redirect because I need some extra processing
but grid does actually produce a basic edit form. If you do use the
grid generated form then the submit should work as normal though. You
should check where it is failing - e.g. when you press submit is it
actually calling the controller?

On Nov 3, 2:16 am, Mike Veltman  wrote:

Now I think of it, you do not need to do a redirect because it creates its own
page based on the called page.

Its just that the submit does not do anything.












SQLFORM.grid does not actually add the records automatically. It just
calls the grid controller with args action/table.
You have to do something like:
 if request.args(0) in ("edit", "new"):
 redirect(URL("edit.html", args=[request.args(1),
request.args(2)])
On Nov 2, 9:15 am, Mike Veltman  wrote:

are you able to see the form? or are you getting the "not authorized
message?"
you can set user_signature=False or ensure that user is logged in.

Thanks for the reaction. But no the form is generated perfectly. And the
user is logged in.

On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman

wrote:

I have
grid =
SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,detai
ls=T rue,searchable=True)
That creates a form with the records with a add button. But when I
use add I
get the next screen but the record is not added. What do I miss ?
Btw is the same setup with a query possible with SQLFORM.smartgrid ?
With regards,
Mike Veltman

With regards,
Mike Veltman

With regards,
Mike Veltman




[web2py] Re: Online Book Typo

2011-11-08 Thread mikech
I was wondering if there was any 'bug' tracking in relation to the 
documentation.  It might be a good idea to track the corrections, and 
changes.

[web2py] Re: uploads folder is empty

2011-11-08 Thread Alex
I'm creating a field and add it to the form like this :

form = SQLFORM(db.image)
my_extra_element = TR(LABEL('test') ,INPUT(_name='test',_type='file'))
form[0].insert(-1,my_extra_element)

if form.process().accepted:
db.image.insert(name='test', image=form.vars['test'])

Maybe my "image=form.vars['test']" is not correct ?

On Nov 8, 9:46 pm, Anthony  wrote:
> It looks like you have attempted to directly store the cgi.FieldStorage
> object in the db field, which won't work. Please show the code used to get
> the file uploaded.
>
> On Tuesday, November 8, 2011 6:16:11 AM UTC-5, Alex wrote:
>
> > I don't know why, but when I upload an image, the uploads folder is
> > empty !
>
> > In my table I can see  :
> > FieldStorage('800x480', 'a800x480.jpg', '\xff\x . xe0\x00')
>
> > In my view I'm doing this :
> > 
> > {{=myTable.name}}
>
> > I can see the name of my image, but no image (that makes sense because
> > my uploads folder is empty)
>
> > I'm on Linux, I did "chmod 777 uploads", but still same pb
>
> > Is there a configuration that I forgot to do ?
>
> > db.define_table('image',
> >   Field('name', length=45),
> >   Field('image', 'upload'),
> > )


Re: [web2py] Re: login form errors

2011-11-08 Thread Matt Broadstone
When I looked at how the generated sample app handled showing that
there was an error with logging in, it showed the message in a flash
area in the view. To be clear here: the controller is a two-liner:

def user():
   return dict(form=auth())

so there is no setup in the controller, as it relates to flash at
least. This lead me to believe that whatever is going on in the
creation of the auth form, it places errors into the session.flash
variable, and I figured I could just add that to my view and the error
would show up. This was not the case.

What I'm really asking here is how to access that error information.
It doesn't appear in session.flash, it doesn't appear in form.errors.

Matt

On Tue, Nov 8, 2011 at 5:08 PM, Cliff  wrote:
> Is there a div with the id of 'flash' in your view?
>
> On Nov 8, 11:14 am, Matt  wrote:
>> Greetings,
>> We are currently experiencing an issue with invalid logins not showing
>> errors. For auth we are using a combination of basic auth and PAM, and
>> the actual controller/view combo for the login form is basically the
>> same as the generated scaffolding. When an invalid username/password
>> is entered the page simply reloads without any indication of what the
>> error was. I tried to display the flash (we are not currently using
>> the session flash, so this had to be added to this page) and that has
>> no info in it, I have also tried to display auth.login_form()'s
>> errors, which do not exist either. Is there some way to get this
>> information?
>>
>> Thank you,
>> Matt


[web2py] Re: uploads folder is empty

2011-11-08 Thread Alex
oh ! I could did it.

As I suspected, my "image=form.vars['test']" was not correct.
Here is the solution :
db.image.insert(name='test',
image=db.image.store(form.vars['test'].file))


On Nov 9, 9:57 am, Alex  wrote:
> I'm creating a field and add it to the form like this :
>
> form = SQLFORM(db.image)
> my_extra_element = TR(LABEL('test') ,INPUT(_name='test',_type='file'))
> form[0].insert(-1,my_extra_element)
>
> if form.process().accepted:
>         db.image.insert(name='test', image=form.vars['test'])
>
> Maybe my "image=form.vars['test']" is not correct ?
>
> On Nov 8, 9:46 pm, Anthony  wrote:
>
> > It looks like you have attempted to directly store the cgi.FieldStorage
> > object in the db field, which won't work. Please show the code used to get
> > the file uploaded.
>
> > On Tuesday, November 8, 2011 6:16:11 AM UTC-5, Alex wrote:
>
> > > I don't know why, but when I upload an image, the uploads folder is
> > > empty !
>
> > > In my table I can see  :
> > > FieldStorage('800x480', 'a800x480.jpg', '\xff\x . xe0\x00')
>
> > > In my view I'm doing this :
> > > 
> > > {{=myTable.name}}
>
> > > I can see the name of my image, but no image (that makes sense because
> > > my uploads folder is empty)
>
> > > I'm on Linux, I did "chmod 777 uploads", but still same pb
>
> > > Is there a configuration that I forgot to do ?
>
> > > db.define_table('image',
> > >   Field('name', length=45),
> > >   Field('image', 'upload'),
> > > )


[web2py] Re: Client side (JS) Accessing to '_extra' field after Ajax/JSON request/response - How?

2011-11-08 Thread Anthony
Very nice summary. Thanks.

On Tuesday, November 8, 2011 6:30:26 PM UTC-5, BrendanC wrote:
>
> FWIW - I just create a new posting with some code that addresses the 
> issues mentioned here.  
>
> Here's the link: 
> https://groups.google.com/forum/#!topic/web2py/CEHLCbMCPw0
>
> Over and Out
> BrendanC
>
>
>

[web2py] Re: Online Book Typo

2011-11-08 Thread Massimo Di Pierro

No but email me.
On Nov 8, 2011, at 6:54 PM, mikech wrote:

I was wondering if there was any 'bug' tracking in relation to the  
documentation.  It might be a good idea to track the corrections,  
and changes.




[web2py] CAS auto login for all apps

2011-11-08 Thread Cahya Dewanta
This is my 7th day using web2py. I have my CAS working properly. But I
have to manually login with same username to each app. Is this normal?
How to make it automatically once login for all? All apps are on the
same domain. Actually I haven't set anything or change any code. The
new web2py did it for me. What setting I have to append? Thank you.


[web2py] Re: lexical scanner

2011-11-08 Thread lucas
ok, i have done so much using this really really cool technique.

anyway, how do i pass a function reference to a "global" storage
context so that the standard views that are stored under views are
rendered properly, like in the above examples?

lucas


Re: [web2py] Re: Online Book Typo

2011-11-08 Thread Vinicius Assef
Massimo,
what about putting the book text in a dvcs? (git, hg, etc.)

Wouldn't it simplify updates?

--
Vinicius Assef.


On Wed, Nov 9, 2011 at 1:15 AM, Massimo Di Pierro
 wrote:
> No but email me.
> On Nov 8, 2011, at 6:54 PM, mikech wrote:
>
>> I was wondering if there was any 'bug' tracking in relation to the
>> documentation.  It might be a good idea to track the corrections, and
>> changes.
>
>


[web2py] Re: access control(RBAC)

2011-11-08 Thread RAMKRISHAN BHATT BACK IN ACTION in bangalore
Use RBAC after referring book . Web2py having very good Roll 
based authentication and access control . Can you please define your 
problem in more precise manner .

[web2py] Conditional presence of a variable in view

2011-11-08 Thread pepper_bg
I have a controller/view like these:

def control():
if some_condition():
return dict(form=form)
else:
return dict(form=form, table=get_table())

{{extend 'layout.html'}}
{{=form}}
{{if table:}}{{=table}}{{pass}}

i.e. 'form' is always present in the view and 'table' sometimes. The
{{if table:}}{{=table}}{{pass}}
condition doesn't seem to be working because when some_condition()
returns true I get:

Traceback (most recent call last):
  File "/pub/web2py/gluon/restricted.py", line 194, in restricted
exec ccode in environment
  File "/pub/web2py/applications/manage/views/default/control.html",
line 86, in 
NameError: name 'table' is not defined

I am missing something silly here. Actually believe this used to work.
Want to rule out view error before I look other places. Thanks for
your help!


[web2py] Re: Conditional presence of a variable in view

2011-11-08 Thread Anthony
No, that should never have worked. To do 'if table:', 'table' does have to 
be defined, and it will only be defined if passed from the controller. 
Here's what you can do:

{{if 'table' in globals():}}

or if there's a chance that when 'table' is actually returned it could be 
None/False/empty and you want to test for that, you could do:

{{if globals().get('table', False):}}

That will be False if 'table' does not exist, but still let you test for 
'table' evaluating to False if it does exist.

You could also do 'return dict(form=form, table=None)' in that first 
condition of your controller, so 'table' will always be defined (again, 
assuming that the second condition would never return None as the value of 
'table').

Anthony


On Wednesday, November 9, 2011 12:36:02 AM UTC-5, pepper_bg wrote:
>
> I have a controller/view like these: 
>
> def control(): 
> if some_condition(): 
> return dict(form=form) 
> else: 
> return dict(form=form, table=get_table()) 
>
> {{extend 'layout.html'}} 
> {{=form}} 
> {{if table:}}{{=table}}{{pass}} 
>
> i.e. 'form' is always present in the view and 'table' sometimes. The 
> {{if table:}}{{=table}}{{pass}} 
> condition doesn't seem to be working because when some_condition() 
> returns true I get: 
>
> Traceback (most recent call last): 
>   File "/pub/web2py/gluon/restricted.py", line 194, in restricted 
> exec ccode in environment 
>   File "/pub/web2py/applications/manage/views/default/control.html", 
> line 86, in  
> NameError: name 'table' is not defined 
>
> I am missing something silly here. Actually believe this used to work. 
> Want to rule out view error before I look other places. Thanks for 
> your help!



Re: [web2py] Re: Online Book Typo

2011-11-08 Thread Anthony
On Tuesday, November 8, 2011 11:26:44 PM UTC-5, viniciusban wrote:
>
> Massimo,
> what about putting the book text in a dvcs? (git, hg, etc.)
>
> Wouldn't it simplify updates?
>
Should include the whole book app -- otherwise it would be difficult to see 
the results of edits made on your local machine.



Re: [web2py] Re: Online Book Typo

2011-11-08 Thread Vinicius Assef
I think only texts are sufficient.

We can send patches to Massimo (or somebody else) merge them in.

--
Vinicius Assef.


On Wed, Nov 9, 2011 at 4:36 AM, Anthony  wrote:
> On Tuesday, November 8, 2011 11:26:44 PM UTC-5, viniciusban wrote:
>>
>> Massimo,
>> what about putting the book text in a dvcs? (git, hg, etc.)
>>
>> Wouldn't it simplify updates?
>
> Should include the whole book app -- otherwise it would be difficult to see
> the results of edits made on your local machine.
>


[web2py] Re: Conditional presence of a variable in view

2011-11-08 Thread pepper_bg
Appreciate it...


[web2py] Re: Online Book Typo

2011-11-08 Thread Gour
On Wed, 9 Nov 2011 02:26:44 -0200
Vinicius Assef 
wrote:

> Massimo,
> what about putting the book text in a dvcs? (git, hg, etc.)

+1



Sincerely,
Gour


-- 
Those who are on this path are resolute in purpose, 
and their aim is one. O beloved child of the Kurus, 
the intelligence of those who are irresolute is many-branched.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature