Re: [web2py] customized the id field in sqlite

2011-10-28 Thread ramesh ramesh
please dont disturb me i am bussy in my bussiness .


[web2py] Re: Best practice of organizing/present static pages

2011-10-28 Thread Anthony
On Saturday, October 29, 2011 1:17:43 AM UTC-4, pbreit wrote:
>
> Not the best urls but could you put them in static?


I assume he meant the main page content is static but the pages still need 
to take advantage of web2py views for navigation, etc., so they aren't true 
"static" files.



Re: [web2py] Re: Appending to a query

2011-10-28 Thread pbreit
Anthony's suggestion is good in general. Bruno's is good if you are not able to 
specify an initial or base query (to add to).


[web2py] Re: Best practice of organizing/present static pages

2011-10-28 Thread pbreit
Not the best urls but could you put them in static?

Even if it's 20 or 50 pages, I would suggest just doing it the web2py way with 
functions.


Re: [web2py] sqlform.grid

2011-10-28 Thread Nik Go
That's nice Peter. Good work!

Thanks for sharing.

On Wednesday, October 26, 2011, peter wrote:

> I am using and enjoying sqlform.grid. I have the latest version of
> web2py, however, I think that the css files within my application have
> become out of date.
>
> If I have ten pages, then the page numbers appear vertically rather
> than horizontally at the bottom of the table.
>
> What css files do I need to copy into my application to keep the css
> up to date for the grid?
>
> Thanks
> Peter


Re: [web2py] SQLFORM.grid awesomeness and some questions

2011-10-28 Thread Nik Go
Johan, we're you able to specify your own icons for your custom buttons? If
so, may I know how you did it?

On Thursday, October 27, 2011, Johann Spies wrote:

>
>
> On 26 October 2011 19:15, Cliff  'cvml', 'cjk...@gmail.com');>> wrote:
>
>> So you need a column on the right for an "Add to Cart" button.
>>
>>
>
> I have previously asked about custom edit buttons and this was the answer
> (which works):
>
> *links = [lambda row: A('Edit',_href=URL("controller","edit",
> args=["update", tablename, a.id]))
> and set editable, deletable, details  to False. **
>
> **If you use jqueryui then the links are rendered as buttons
>
> *The buttons created this way each appears in an extra column.
>
> Regards
> Johann
>  --
> Because experiencing your loyal love is better than life itself,
> my lips will praise you.  (Psalm 63:3)
>
>


Re: [web2py] sqlform.grid and represent vs. format

2011-10-28 Thread Nik Go
I experience the same unexpected behavior.

On Friday, October 28, 2011, szimszon wrote:

> I have to tables
>
> db.define_table( 'wdirs',
> Field( 'name', type = 'string',
> requires = IS_NOT_EMPTY()),
> *(a)* *format='%(name)s %(id)s'*
> )
>
> db.define_table( 'files',
> Field( 'wdirs_id', db.wdirs,
> requires = IS_IN_DB( db, db.wdirs.id, "%(name)s
> %(id)s" ),
> *(b)* *represent = lambda id, row: row.wdirs_id.name*)
> )
>
> If I remove *(b)* than the SQLFORM.grid(db.files) displays only the record
> id in wdirs_id column. The wdirs' table format parameter isn't honored. I
> have to make the represent to be able to display the name of the wdir not
> only the record id.
>
> Am I right or I miss something?
>


Re: [web2py] SQLFORM.grid collection of posts

2011-10-28 Thread Nik Go
It mentions: "If you use jqueryui then the links are rendered as buttons. "

am still trying to find an answer about how to use icons for your custom
buttons.

On Friday, October 28, 2011, Cliff wrote:

> I'll try to keep an eye on it.
>
> On Oct 27, 1:47 pm, Massimo Di Pierro 
> 
> >
> wrote:
> > Thanks this is useful! Mind that the API may still fluctuate a bit.
> >
> > On Oct 26, 4:38 pm, Cliff > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > You can find a digest of posts about SQLFORM.grid here:
> >
> > >https://docs.google.com/document/d/1p-OXDn75Nt2qmXQ0lvjqr4tYIf2PTIQx6.
> ..
> >
> > > I know it is not complete, but it may help you get started.
> >
> > > Also there is some good information in the source file: gluon/
> > > sqlhtml,  Just looking at the signature of the grid function is very
> > > instructive.
> >
> > > If you find something I've missed, just let me know.
> >
> > > Cliff Kachinske


[web2py] Re: Best practice of organizing/present static pages

2011-10-28 Thread Anthony
Also, using the parameter-based router, you could make 'content' the 
default function, so it would be hidden in the URL.

On Friday, October 28, 2011 9:58:58 PM UTC-4, Anthony wrote:
>
> You could create a single function (maybe call it something like 
> 'content') and pass an argument in the URL to determine the view to display:
>
> def content():
> response.view = 'default/%s.%s' % (request.args(0), request.extension) 
> if request.args else 'default/index.html'
> return dict()
>
> URLs would look like /app/default/content/intro1-page1, etc. If you'd 
> prefer something like /intro1/page1, you could use request.args(0) and 
> request.args(1).
>
> Anthony
>
> On Friday, October 28, 2011 9:02:50 PM UTC-4, Spring wrote:
>>
>> Dear All, 
>>
>> I'm developing a website for introduction of something. In this case 
>> there is quite a lot of static contents (img+text) spreading over 
>> several pages, like: 
>>
>> Home 
>> |-Introduction 1 
>> ||-page 1 
>> ||-page 2 
>> ||- 
>> |-Introduction 2 
>> ||-... 
>> ... 
>>
>> I would like to know what is the best practice to show these static 
>> pages? Based on my understanding of web2py using MVC, the solution I 
>> come up with is to create a function for each "click" or page. But the 
>> will end up having many functions doing almost nothing but only to 
>> trigger the view and present these static pages. So I would like to 
>> know if there is better practice to handle this. 
>>
>> Any suggestion is welcome. 
>>
>> Spring
>
>

[web2py] Re: Best practice of organizing/present static pages

2011-10-28 Thread Anthony
You could create a single function (maybe call it something like 'content') 
and pass an argument in the URL to determine the view to display:

def content():
response.view = 'default/%s.%s' % (request.args(0), request.extension) 
if request.args else 'default/index.html'
return dict()

URLs would look like /app/default/content/intro1-page1, etc. If you'd 
prefer something like /intro1/page1, you could use request.args(0) and 
request.args(1).

Anthony

On Friday, October 28, 2011 9:02:50 PM UTC-4, Spring wrote:
>
> Dear All, 
>
> I'm developing a website for introduction of something. In this case 
> there is quite a lot of static contents (img+text) spreading over 
> several pages, like: 
>
> Home 
> |-Introduction 1 
> ||-page 1 
> ||-page 2 
> ||- 
> |-Introduction 2 
> ||-... 
> ... 
>
> I would like to know what is the best practice to show these static 
> pages? Based on my understanding of web2py using MVC, the solution I 
> come up with is to create a function for each "click" or page. But the 
> will end up having many functions doing almost nothing but only to 
> trigger the view and present these static pages. So I would like to 
> know if there is better practice to handle this. 
>
> Any suggestion is welcome. 
>
> Spring



Re: [web2py] Re: Massimo Di Pierro talks about web2py on FLOSS Weekly

2011-10-28 Thread Ovidio Marinho
  Excellent testimony, you could prepare an academic version to
incorporate the library of examples of web2py.


   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



2011/10/28 peter 

> I have just written an ecommerce site in web2py. ukjazz.net. At the
> moment it is in demo form, so you can buy things for free when you
> click pay now. You will find that then it has things like view
> downloads, and view order history. It also has a facility for the
> record labels to look at their sales. I orginally choose Zencart
> because it was open source (php). It is far too complex, 4000 files!
> It was a very tricky business modifying it to my needs. I also hated
> PHP etc. I am expreinced enough at software support to know that
> launching a site with such a complex software base was creating a rod
> for my back in the future. I looked around at lots of approaches like
> Django and ruby for rails etc. I ended up with web2py and python. My
> main fear was that Web2py looked to good to be true, and I follow the
> motto 'If something looks too good to be true it probably is too good
> to be true'. However web2py delivered fantastically. I have a lot of
> exprience both in academia and outside it. I find that Web2py
> incorporates a lot of good practice. The end result is extraordinary.
> The huge complex zencart php program has been replaced by somthing
> relatively straightforward and elegant. Something so much easier to
> develop and maintain. Writing it was not a lot more work than
> modifying zencart to my needs. The actual ecommerce bit was somewhat
> less than a months work, and remember I started not knowing python and
> not knowing web2py, so a lot of that was working out how to do things.
>
> So I think that web2py is well suited to ecommerce. The book is pretty
> good, the forum extraordinarily helpful. The rate of development great
> too. Prior to this project I was very experienced programmer, but had
> real experience of web programming or SQL. Seeing how horrible web
> programming can be, Web2py has created a virtual machine on top of the
> web, and this virtual machine is much nicer to use. It has also
> sheltered me from having to learn the ugliness of SQL.
>
> So thanks to all those involved in this great project. Thanks in
> particular of course to Massimo. Massimo reminds me of Nikluas Wirth.
> I used to devlop programs in C and at that time they were very
> difficult to debug. I then tried Modula 2. When my progams compiled
> cleanly they usually worked straight away. The elegance of Modula 2 is
> similar to me the elgance of Web2py. (This is a double edged
> compliment as Modula 2 became unsupported due to the arrival of ADA
> and C++, a fate it did not deserve). I was a programmer before I
> became a lecturer. Lecturing on programming made me understand
> programming a lot better. Both Niklaus and Massimo encompassed that
> kind of learning in better tools which incorporate good practice.  It
> is extraodinary the critisism that Massimo gets from some quarters
> because he has made a very large number of very wise choices in the
> design of Web2py. The simplicity of the solutions do not always meke
> this clear. The team also manage a rather extraodinary feat in both
> keeping Web2py kind of stable and yet developing at a rate at the same
> time. The biggest problem is that the most useful things are not yet
> documented at all. However I would much rather use them undocumented
> than have to wait until they are fully tested and documented.
>
>
> Peter
>
>
>
>
>
>
>
>
> On Oct 28, 9:21 pm, Gour  wrote:
> > On Wed, 26 Oct 2011 17:17:51 -0200
> >
> > Bruno Rocha  wrote:
> > > VIDEO:http://twit.tv/show/floss-weekly/188
> >
> > Watched video today...very nice presentation fo Web2py!
> >
> > One question: Massimo mentioned that web2py is going to move to github
> soon and
> > I wonder whether one will be able to still use hg to fetch the code?
> >
> > Moreover, what about other projects like Instant Press being hosted at
> > Bitbucket?
> >
> > Few days ago I had to move one SilverStripe site to WP not being able to
> use IP
> > where some basic things like rendering of unordered lists is not proper
> (no
> > bullets).
> >
> > Otoh, I really do not want to delve into PHP web programming, and would
> like to
> > deploy Web2py for all my web needs, so having more web2py stuff under one
> > umbrella (even if it's called github) might be good and would (hopefully)
> > result in better docs as well as quicker fixes for web2py-related
> > projects like Instant Press...
> >
> > One more concern: Massimo answered during the show that Web2py is mostly
> used
> > in Intranet. so I wonder if there is, in general, enthusiasm withing this
> > community to push out to build Internet sites 

[web2py] CSS3PIE

2011-10-28 Thread Daniel Aguayo

Hi all,

I want to share that CSSPIE could be a good prospect to include in 
web2py. From its website:


"PIE stands for Progressive Internet Explorer. It is an IE attached 
behavior which, when applied to an element, allows IE to recognize and 
display a number of CSS3 properties."


It is currently in version 1.0beta5

Regards.
Daniel Aguayo Catalán


[web2py] Best practice of organizing/present static pages

2011-10-28 Thread YesYesYes++
Dear All,

I'm developing a website for introduction of something. In this case
there is quite a lot of static contents (img+text) spreading over
several pages, like:

Home
|-Introduction 1
||-page 1
||-page 2
||-
|-Introduction 2
||-...
...

I would like to know what is the best practice to show these static
pages? Based on my understanding of web2py using MVC, the solution I
come up with is to create a function for each "click" or page. But the
will end up having many functions doing almost nothing but only to
trigger the view and present these static pages. So I would like to
know if there is better practice to handle this.

Any suggestion is welcome.

Spring


[web2py] unql

2011-10-28 Thread elffikk
hi,

I am thinking how to extend DAL so it could be suitable for OriendDB
SQL
or for
http://www.unqlspec.org/display/UnQL/Home

do you have any thoughts on that?

gae storage is already an example of DAL variations by not supporting
joins and other features


[web2py] SparkleShare

2011-10-28 Thread Robert Marklund
If someone is looking for a nice mission with web2py why not create a
web UI for the sparkleshare service.
More info here:
http://sparkleshare.org/
https://github.com/hbons/SparkleShare

Whats available today:
https://github.com/hbons/SparkleShare-Dashboard

/R


[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread Anthony
On Friday, October 28, 2011 6:50:20 PM UTC-4, TheSweetlink wrote:
>
> Do you mean something like use jQuery from the outer part of the page 
> which contains the component? 
>
> I do not know how I would do that.  I tried something along those 
> lines unsuccessfully before but I may have just implemented it 
> incorrectly. 
>
> My trouble is having js interact with the stuff loaded into the 
> component, from outside the component.
>

Yes. The component is just a div in the page, so JS from outside the 
component should be able to interact with it. In fact, you can have one 
component interact with another (e.g., clicking a link in one component can 
trigger another to reload).

Anthony


[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread TheSweetlink
Do you mean something like use jQuery from the outer part of the page
which contains the component?

I do not know how I would do that.  I tried something along those
lines unsuccessfully before but I may have just implemented it
incorrectly.

My trouble is having js interact with the stuff loaded into the
component, from outside the component.

What you say makes sense though, I'll play around with that.

Thank you for you suggestions Anthony.

On Oct 28, 6:40 pm, Anthony  wrote:
> Since the whole page isn't reloading, can't you capture what is being typed
> using Javascript and then fill the content back in once the component
> refreshes (i.e., do everything client side)?
>
> On Friday, October 28, 2011 5:56:54 PM UTC-4, TheSweetlink wrote:
>
> > Hi Anthony and thanks for your reply.
>
> > I do not believe that I can separate the form from the component.
>
> > Think of the component like a message board with a form up top for a
> > main post with comment forms for each post all wrapped into one
> > component.
>
> > All of the forms get blanked upon component reload as that's their
> > original state.
>
> > Any post or comment being typed retains focus for the correct form,
> > but is blanked.
>
> > Even if I broke the component down to two (post and comment) comments
> > would get blanked upon component refresh showing new posts.
>
> > I will attempt my first idea of using web2py's ajax() and a session
> > var and test the performance as it may not be so horrible but I would
> > prefer to have a more efficient method if possible.
>
> > Do you have any other tricks to try?
>
> > David
>
> > On Oct 28, 3:48 pm, Anthony  wrote:
> > > Can you separate the form being typed in from the data being displayed
> > by
> > > the refresh (i.e., maybe used two separate components)?
>
> > > On Friday, October 28, 2011 3:16:41 PM UTC-4, TheSweetlink wrote:
>
> > > > I have an app that polls for new messages and reloads a component when
> > > > there are new messages.
>
> > > > My problem is that when the component is refreshed/reloaded while a
> > > > user is typing, the message being typed disappears.
>
> > > > This makes sense because the component contains the form being
> > > > submitted.  For example refreshing the page before a form submission,
> > > > the refreshed page won't contain whatever was being typed.
>
> > > > I wish to retain the form data after the component is refreshed so
> > > > that the user can continue typing a message without having everything
> > > > blanked every time a new message appears.
>
> > > > What do you recommend as a method to keep what is being typed across a
> > > > component reload?
>
> > > > All I can think of right now is using web2py's ajax() to keep feeding
> > > > a session var whatever is being typed using JQuery's .change()
>
> > > > If there is anything in the session var, display it after the
> > > > component reload.  Upon form submission, clear the session var.
>
> > > > It just seems awfully inefficient to update a session var with the
> > > > ajax function for every character typed.
>
> > > > Can you suggest a smarter way of retaining the form's data after a
> > > > component reload?
>
> > > > Your help is most appreciated.
>
> > > > David
>
>


[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread Anthony
Since the whole page isn't reloading, can't you capture what is being typed 
using Javascript and then fill the content back in once the component 
refreshes (i.e., do everything client side)?

On Friday, October 28, 2011 5:56:54 PM UTC-4, TheSweetlink wrote:
>
> Hi Anthony and thanks for your reply. 
>
> I do not believe that I can separate the form from the component. 
>
> Think of the component like a message board with a form up top for a 
> main post with comment forms for each post all wrapped into one 
> component. 
>
> All of the forms get blanked upon component reload as that's their 
> original state. 
>
> Any post or comment being typed retains focus for the correct form, 
> but is blanked. 
>
> Even if I broke the component down to two (post and comment) comments 
> would get blanked upon component refresh showing new posts. 
>
> I will attempt my first idea of using web2py's ajax() and a session 
> var and test the performance as it may not be so horrible but I would 
> prefer to have a more efficient method if possible. 
>
> Do you have any other tricks to try? 
>
> David 
>
> On Oct 28, 3:48 pm, Anthony  wrote: 
> > Can you separate the form being typed in from the data being displayed 
> by 
> > the refresh (i.e., maybe used two separate components)? 
> > 
> > On Friday, October 28, 2011 3:16:41 PM UTC-4, TheSweetlink wrote: 
> > 
> > > I have an app that polls for new messages and reloads a component when 
> > > there are new messages. 
> > 
> > > My problem is that when the component is refreshed/reloaded while a 
> > > user is typing, the message being typed disappears. 
> > 
> > > This makes sense because the component contains the form being 
> > > submitted.  For example refreshing the page before a form submission, 
> > > the refreshed page won't contain whatever was being typed. 
> > 
> > > I wish to retain the form data after the component is refreshed so 
> > > that the user can continue typing a message without having everything 
> > > blanked every time a new message appears. 
> > 
> > > What do you recommend as a method to keep what is being typed across a 
> > > component reload? 
> > 
> > > All I can think of right now is using web2py's ajax() to keep feeding 
> > > a session var whatever is being typed using JQuery's .change() 
> > 
> > > If there is anything in the session var, display it after the 
> > > component reload.  Upon form submission, clear the session var. 
> > 
> > > It just seems awfully inefficient to update a session var with the 
> > > ajax function for every character typed. 
> > 
> > > Can you suggest a smarter way of retaining the form's data after a 
> > > component reload? 
> > 
> > > Your help is most appreciated. 
> > 
> > > David 
> > 
> >



[web2py] Re: Massimo Di Pierro talks about web2py on FLOSS Weekly

2011-10-28 Thread Anthony
On Friday, October 28, 2011 4:21:30 PM UTC-4, Gour wrote:
>
>
> One more concern: Massimo answered during the show that Web2py is mostly 
> used
> in Intranet. so I wonder if there is, in general, enthusiasm withing this
> community to push out to build Internet sites as well and having
> CMS/blog/ecommerce modules available or is web2py simply more suitable for 
> the
> former use-case?
>
There's no reason in principle not to use web2py for public websites, and 
obviously many people have (http://www.web2py.com/poweredby). Though most 
of those sites probably don't get particularly high traffic and aren't well 
known, there are some nice examples in that list.

Anthony
 


[web2py] ldap_auth bug report

2011-10-28 Thread Carlos Hanson
Greetings,

We use DNS in our Active Directory domain, so we get some extra results in 
a search:

  [(None, 
['ldap://ForestDnsZones.domain.com/DC=ForestDnsZones,DC=domain,DC=com']),
   (None, 
['ldap://DomainDnsZones.domain.com/DC=DomainDnsZones,DC=ttsd,DC=ttsd,DC=k12,DC=or,DC=us']),
   (None, ['ldap://domain.com/CN=Configuration,DC=domain,DC=com'])]

When a search is made at login for the account, the value of result ends up 
being a list rather than a dictionary with the value of sAMAccountName.

The following patch does a simple test of the type and returns False if it 
is not a dict. I tried to attach the patch file to this message, but got a 
communication error.

--- gluon/contrib/login_methods/ldap_auth.py.org2011-10-28 
12:26:01.0 -0700
+++ gluon/contrib/login_methods/ldap_auth.py2011-10-28 
14:42:34.0 -0700
@@ -97,6 +97,12 @@
 result = con.search_ext_s(
 ldap_basedn, ldap.SCOPE_SUBTREE,
 "(&(sAMAccountName=%s)(%s))" % (username_bare, 
filterstr), ["sAMAccountName"])[0][1]
+# In cases where ForestDnsZones and DomainDnsZones are 
found,
+# result will look like the following:
+# 
['ldap://ForestDnsZones.domain.com/DC=ForestDnsZones,DC=domain,DC=com']
+if not isinstance(result, dict):
+# result should be a dict in the form 
{'sAMAccountName': [username_bare]}
+return False
 if ldap_binddn:
 # We know the user exists & is in the correct OU
 # so now we just check the password


As an aside, I am really enjoying web2py.

Carlos Hanson


[web2py] Re: Caching a gluon.storage.Storage instance on GAE

2011-10-28 Thread howesc
can you suggest an improvement to storage to make it pickable on GAE?  i 
certainly would use it. :)


Re: [web2py] Re: Massimo Di Pierro talks about web2py on FLOSS Weekly

2011-10-28 Thread Justin Heath
You can use hg-git to interface with git repos from mercurial.

http://hg-git.github.com/

On Fri, Oct 28, 2011 at 4:21 PM, Gour  wrote:
> On Wed, 26 Oct 2011 17:17:51 -0200
> Bruno Rocha  wrote:
>
>> VIDEO: http://twit.tv/show/floss-weekly/188
>
> Watched video today...very nice presentation fo Web2py!
>
> One question: Massimo mentioned that web2py is going to move to github soon 
> and
> I wonder whether one will be able to still use hg to fetch the code?
>
> Moreover, what about other projects like Instant Press being hosted at
> Bitbucket?
>
> Few days ago I had to move one SilverStripe site to WP not being able to use 
> IP
> where some basic things like rendering of unordered lists is not proper (no
> bullets).
>
> Otoh, I really do not want to delve into PHP web programming, and would like 
> to
> deploy Web2py for all my web needs, so having more web2py stuff under one
> umbrella (even if it's called github) might be good and would (hopefully)
> result in better docs as well as quicker fixes for web2py-related
> projects like Instant Press...
>
> One more concern: Massimo answered during the show that Web2py is mostly used
> in Intranet. so I wonder if there is, in general, enthusiasm withing this
> community to push out to build Internet sites as well and having
> CMS/blog/ecommerce modules available or is web2py simply more suitable for the
> former use-case?
>
>
> Sincerely,
> Gour
>
>
> --
> One who restrains his senses, keeping them under full control,
> and fixes his consciousness upon Me, is known as a man of
> steady intelligence.
>
> http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810
>


[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread TheSweetlink
Hi Anthony and thanks for your reply.

I do not believe that I can separate the form from the component.

Think of the component like a message board with a form up top for a
main post with comment forms for each post all wrapped into one
component.

All of the forms get blanked upon component reload as that's their
original state.

Any post or comment being typed retains focus for the correct form,
but is blanked.

Even if I broke the component down to two (post and comment) comments
would get blanked upon component refresh showing new posts.

I will attempt my first idea of using web2py's ajax() and a session
var and test the performance as it may not be so horrible but I would
prefer to have a more efficient method if possible.

Do you have any other tricks to try?

David

On Oct 28, 3:48 pm, Anthony  wrote:
> Can you separate the form being typed in from the data being displayed by
> the refresh (i.e., maybe used two separate components)?
>
> On Friday, October 28, 2011 3:16:41 PM UTC-4, TheSweetlink wrote:
>
> > I have an app that polls for new messages and reloads a component when
> > there are new messages.
>
> > My problem is that when the component is refreshed/reloaded while a
> > user is typing, the message being typed disappears.
>
> > This makes sense because the component contains the form being
> > submitted.  For example refreshing the page before a form submission,
> > the refreshed page won't contain whatever was being typed.
>
> > I wish to retain the form data after the component is refreshed so
> > that the user can continue typing a message without having everything
> > blanked every time a new message appears.
>
> > What do you recommend as a method to keep what is being typed across a
> > component reload?
>
> > All I can think of right now is using web2py's ajax() to keep feeding
> > a session var whatever is being typed using JQuery's .change()
>
> > If there is anything in the session var, display it after the
> > component reload.  Upon form submission, clear the session var.
>
> > It just seems awfully inefficient to update a session var with the
> > ajax function for every character typed.
>
> > Can you suggest a smarter way of retaining the form's data after a
> > component reload?
>
> > Your help is most appreciated.
>
> > David
>
>


Re: [web2py] Re: Appending to a query

2011-10-28 Thread Bruno Rocha
http://showmethecode.tumblr.com/post/9583103076/web2pydaldynamicqueries


Re: [web2py] Re: Google App Engine (GAE) does not support database LIKE statement...

2011-10-28 Thread Bruno Rocha
http://showmethecode.tumblr.com/post/9624208451/likeingae

On Fri, Oct 28, 2011 at 5:41 PM, $p00ky  wrote:

> Find answer:
> http://stackoverflow.com/questions/4512181/web2py-like-equivalents-with-google-app-engine
>
> So a real equivalent is not possible super..
>



-- 

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


[web2py] Re: Massimo Di Pierro talks about web2py on FLOSS Weekly

2011-10-28 Thread peter
I have just written an ecommerce site in web2py. ukjazz.net. At the
moment it is in demo form, so you can buy things for free when you
click pay now. You will find that then it has things like view
downloads, and view order history. It also has a facility for the
record labels to look at their sales. I orginally choose Zencart
because it was open source (php). It is far too complex, 4000 files!
It was a very tricky business modifying it to my needs. I also hated
PHP etc. I am expreinced enough at software support to know that
launching a site with such a complex software base was creating a rod
for my back in the future. I looked around at lots of approaches like
Django and ruby for rails etc. I ended up with web2py and python. My
main fear was that Web2py looked to good to be true, and I follow the
motto 'If something looks too good to be true it probably is too good
to be true'. However web2py delivered fantastically. I have a lot of
exprience both in academia and outside it. I find that Web2py
incorporates a lot of good practice. The end result is extraordinary.
The huge complex zencart php program has been replaced by somthing
relatively straightforward and elegant. Something so much easier to
develop and maintain. Writing it was not a lot more work than
modifying zencart to my needs. The actual ecommerce bit was somewhat
less than a months work, and remember I started not knowing python and
not knowing web2py, so a lot of that was working out how to do things.

So I think that web2py is well suited to ecommerce. The book is pretty
good, the forum extraordinarily helpful. The rate of development great
too. Prior to this project I was very experienced programmer, but had
real experience of web programming or SQL. Seeing how horrible web
programming can be, Web2py has created a virtual machine on top of the
web, and this virtual machine is much nicer to use. It has also
sheltered me from having to learn the ugliness of SQL.

So thanks to all those involved in this great project. Thanks in
particular of course to Massimo. Massimo reminds me of Nikluas Wirth.
I used to devlop programs in C and at that time they were very
difficult to debug. I then tried Modula 2. When my progams compiled
cleanly they usually worked straight away. The elegance of Modula 2 is
similar to me the elgance of Web2py. (This is a double edged
compliment as Modula 2 became unsupported due to the arrival of ADA
and C++, a fate it did not deserve). I was a programmer before I
became a lecturer. Lecturing on programming made me understand
programming a lot better. Both Niklaus and Massimo encompassed that
kind of learning in better tools which incorporate good practice.  It
is extraodinary the critisism that Massimo gets from some quarters
because he has made a very large number of very wise choices in the
design of Web2py. The simplicity of the solutions do not always meke
this clear. The team also manage a rather extraodinary feat in both
keeping Web2py kind of stable and yet developing at a rate at the same
time. The biggest problem is that the most useful things are not yet
documented at all. However I would much rather use them undocumented
than have to wait until they are fully tested and documented.


Peter








On Oct 28, 9:21 pm, Gour  wrote:
> On Wed, 26 Oct 2011 17:17:51 -0200
>
> Bruno Rocha  wrote:
> > VIDEO:http://twit.tv/show/floss-weekly/188
>
> Watched video today...very nice presentation fo Web2py!
>
> One question: Massimo mentioned that web2py is going to move to github soon 
> and
> I wonder whether one will be able to still use hg to fetch the code?
>
> Moreover, what about other projects like Instant Press being hosted at
> Bitbucket?
>
> Few days ago I had to move one SilverStripe site to WP not being able to use 
> IP
> where some basic things like rendering of unordered lists is not proper (no
> bullets).
>
> Otoh, I really do not want to delve into PHP web programming, and would like 
> to
> deploy Web2py for all my web needs, so having more web2py stuff under one
> umbrella (even if it's called github) might be good and would (hopefully)
> result in better docs as well as quicker fixes for web2py-related
> projects like Instant Press...
>
> One more concern: Massimo answered during the show that Web2py is mostly used
> in Intranet. so I wonder if there is, in general, enthusiasm withing this
> community to push out to build Internet sites as well and having
> CMS/blog/ecommerce modules available or is web2py simply more suitable for the
> former use-case?
>
> Sincerely,
> Gour
>
> --
> One who restrains his senses, keeping them under full control,
> and fixes his consciousness upon Me, is known as a man of
> steady intelligence.
>
> http://atmarama.net| Hlapicina (Croatia) | GPG: 52B5C810
>
>  signature.asc
> < 1KViewDownload


[web2py] Best practices for packaging an app?

2011-10-28 Thread Matt Gorecki
I've built an app that I'd like to give to someone to use.  It's
essentially a photo booth program.  It's built in web2py, but it also
requires node.js, gphoto2, Chrome, as well as some configuration
changes to Gnome.

What's the best way to package something like this?  Can my
'installer' handle the dependencies, or do the install instructions
just show how to install node.js and gphoto?  How do I deal with the
system changes like the Gnome setttings?


[web2py] Re: Massimo Di Pierro talks about web2py on FLOSS Weekly

2011-10-28 Thread Gour
On Wed, 26 Oct 2011 17:17:51 -0200
Bruno Rocha  wrote:

> VIDEO: http://twit.tv/show/floss-weekly/188

Watched video today...very nice presentation fo Web2py!

One question: Massimo mentioned that web2py is going to move to github soon and
I wonder whether one will be able to still use hg to fetch the code?

Moreover, what about other projects like Instant Press being hosted at
Bitbucket?

Few days ago I had to move one SilverStripe site to WP not being able to use IP
where some basic things like rendering of unordered lists is not proper (no
bullets).

Otoh, I really do not want to delve into PHP web programming, and would like to
deploy Web2py for all my web needs, so having more web2py stuff under one
umbrella (even if it's called github) might be good and would (hopefully)
result in better docs as well as quicker fixes for web2py-related
projects like Instant Press...

One more concern: Massimo answered during the show that Web2py is mostly used
in Intranet. so I wonder if there is, in general, enthusiasm withing this
community to push out to build Internet sites as well and having
CMS/blog/ecommerce modules available or is web2py simply more suitable for the
former use-case?


Sincerely,
Gour


-- 
One who restrains his senses, keeping them under full control, 
and fixes his consciousness upon Me, is known as a man of 
steady intelligence.

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


signature.asc
Description: PGP signature


[web2py] Re: Caching a gluon.storage.Storage instance on GAE

2011-10-28 Thread pepper_bg
Just rewrote the thing to use not nested Storages but dicts and the
problem went away. C'mon, GAE...


[web2py] Re: Appending to a query

2011-10-28 Thread Anthony
Maybe:

query &= ~db.mytable.id.belongs(blacklist)

or just:

query = query & another_condition

On Friday, October 28, 2011 3:45:45 PM UTC-4, Cliff wrote:
>
> I'm pretty sure I saw a thread about this, but I can't find it. 
>
> I need to do something like 
>
> query = ((db.mytable.id==somevalue) & (db.mytable.active==True)) 
>
> if blacklist: 
> query.append(~db.mytable.id.belongs(blacklist)) 
>
> How do I do this? 
>
> The reason I'm doing this is psycopg2 raises an exception if the query 
> contains NOT IN().



[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread Anthony
Can you separate the form being typed in from the data being displayed by 
the refresh (i.e., maybe used two separate components)?

On Friday, October 28, 2011 3:16:41 PM UTC-4, TheSweetlink wrote:
>
> I have an app that polls for new messages and reloads a component when 
> there are new messages. 
>
> My problem is that when the component is refreshed/reloaded while a 
> user is typing, the message being typed disappears. 
>
> This makes sense because the component contains the form being 
> submitted.  For example refreshing the page before a form submission, 
> the refreshed page won't contain whatever was being typed. 
>
> I wish to retain the form data after the component is refreshed so 
> that the user can continue typing a message without having everything 
> blanked every time a new message appears. 
>
> What do you recommend as a method to keep what is being typed across a 
> component reload? 
>
> All I can think of right now is using web2py's ajax() to keep feeding 
> a session var whatever is being typed using JQuery's .change() 
>
> If there is anything in the session var, display it after the 
> component reload.  Upon form submission, clear the session var. 
>
> It just seems awfully inefficient to update a session var with the 
> ajax function for every character typed. 
>
> Can you suggest a smarter way of retaining the form's data after a 
> component reload? 
>
> Your help is most appreciated. 
>
> David



[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Anthony
On Friday, October 28, 2011 3:02:11 PM UTC-4, Ross Peoples wrote:
>
> I was originally going to suggest checking for FieldStorage rather than 
> StringIO, but wasn't sure if I wanted to suggest adding another import (of 
> cgi).


Maybe hasattr(file, 'file') would be sufficient. I'm not sure file has to 
or will be a StringIO object specifically, so probably better to try to 
positively identify the FieldStorage case rather than attempt to positively 
identify the non-FieldStorage case.

Anthony 



[web2py] Appending to a query

2011-10-28 Thread Cliff
I'm pretty sure I saw a thread about this, but I can't find it.

I need to do something like

query = ((db.mytable.id==somevalue) & (db.mytable.active==True))

if blacklist:
query.append(~db.mytable.id.belongs(blacklist))

How do I do this?

The reason I'm doing this is psycopg2 raises an exception if the query
contains NOT IN().


[web2py] Re: Google App Engine (GAE) does not support database LIKE statement...

2011-10-28 Thread $p00ky
Find answer: 
http://stackoverflow.com/questions/4512181/web2py-like-equivalents-with-google-app-engine

So a real equivalent is not possible super..


Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-28 Thread thodoris
Hi  Hong-Khoan,

Sure, send it to me and i will try it.

Regards,

Thodoris


[web2py] Google App Engine (GAE) does not support database LIKE statement...

2011-10-28 Thread $p00ky
Dear all,

Apparently, Google App Engine datastore does not support "WHERE myfield 
LIKE '%search%'" feature...

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/restricted.py", 
line 194, in restricted
exec ccode in environment
  File 
"/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/applications/ddlagoon/controllers/default.py:index",
 line 365, in 
  File 
"/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/globals.py", line 
149, in 
self._caller = lambda f: f()
  File 
"/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/applications/ddlagoon/controllers/default.py:index",
 line 75, in index
  File "/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/dal.py", 
line 5697, in select
return self.db._adapter.select(self.query,fields,attributes)
  File "/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/dal.py", 
line 3351, in select
(items, tablename, fields) = self.select_raw(query,fields,attributes)
  File "/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/dal.py", 
line 3308, in select_raw
filters = self.expand(query)
  File "/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/dal.py", 
line 3190, in expand
return expression.op(expression.first, expression.second)
  File "/base/data/home/apps/s~ddl-lagoon/1.354289280423718203/gluon/dal.py", 
line 3267, in CONTAINS
raise SyntaxError, "Not supported"
SyntaxError: Not supported



Is there any way to get the same effect in GAE?

How can we "search" into the datastore? 



[web2py] Mongo DB, AMFRPC3 and http 500 errors

2011-10-28 Thread Mike D
Hi,

I'm pretty new to python, mongoDB and pymongo so I'm hoping this is
pretty easy to track down. When I invoke the following method from a
flex client I am seeing the error described below:

@service.amfrpc3("mydomain")
def test():
dbh = getConnection()
record =
dbh.events.find_one({"event_id":"{42152cf8-6a8c-5566-3d51-79915b6fbcb2}"})
returnableRecord = dict()
returnableRecord["event_id"] = record["event_id"]
return record;
#return returnableRecord;

The other important code for this method is as follows:
service = Service(globals())

def call():
session.forget()
return service()

def getConnection():
try:
conn = Connection('localhost', 27017)
except ConnectionFailure, e:
msg = "Failed to connect: %s" %e
print(msg)

dbh = conn["db"]
return dbh

The client side object looks like this:
http://127.0.0.1:8000/timestream_server/rpc/call/amfrpc3";
destination="mydomain"
showBusyCursor="true">


Here's the error:
faultCode:Channel.Call.Failed faultString:'error'
faultDetail:'NetConnection.Call.Failed: HTTP: Status 500'

If I comment out the "return record" in the test function and
uncomment the line below it ("return returnableRecord") then
everything works fine. No error and the flex client gets the right
thing. I have used a step debugger to step through the code and see
where the exception was being generated on the server and I found this
in a file called restricted.py:


def restricted(code, environment=None, layer='Unknown'):
"""
runs code in environment and returns the output. if an exception
occurs
in code it raises a RestrictedError containing the traceback.
layer is
passed to RestrictedError to identify where the error occurred.
"""
if environment is None: environment = {}
environment['__file__'] = layer
try:
if type(code) == types.CodeType:
ccode = code
else:
ccode = compile2(code,layer)
exec ccode in environment
except HTTP:
raise
except Exception, error:
# XXX Show exception in Wing IDE if running in debugger
if __debug__ and 'WINGDB_ACTIVE' in os.environ:
etype, evalue, tb = sys.exc_info()
sys.excepthook(etype, evalue, tb)
raise RestrictedError(layer, code, '', environment)

The second exception block is entered and the exception is:
AttributeError: 'ObjectId' object has no attribute 'i'

I have no idea what could be causing this. Any help would be greatly
appreciated.

Thanks,
Mike


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread TheSweetlink
Hello Ross,

Here is a bunch of info from another post I made regarding manual
uploads with SQLFORM.factory.

Now that I notice it though, you are using FORM and I'm uncertain
whether or not FORM worked for me, I had to use SQLFORM.

The whole thread can be found here for more info, relevant stuff
posted below:

http://groups.google.com/group/web2py/browse_thread/thread/fe03404c155aaf10/f9cb6c1ac67c3f49?lnk=gst&q=thesweetlink#f9cb6c1ac67c3f49

Two things I've found when manually uploading via SQLFORM.factory:

1)  You need to specify a table_name='...' to avoid the
no_table_newfilename.extension issue like this:

form = SQLFORM.factory(...Field definitions...,
table_name='some_table_name')

2)  Additionally you must specify an uploadfolder in your upload Field
definition similar to this:

form = SQLFORM.factory(...,
Field('invoice_logo', type='upload',
uploadfolder=os.path.join(request.folder,'static/uploads/')),
..., table_name='whatever_you_like')

**NOTE** 'static/uploads' is just an example, you can upload to
wherever it will be appropriate.

In this case the newly uploaded and renamed file to
your_application's_dir/static/uploads/your_new_filename_here

One gotcha to look out for following your field name as an example
without the quotation marks:

In your form.accepts(...):

"request.vars.invoice_logo" will contain the original filename of your
upload whereas

"form.vars.invoice_logo_newfilename" will contain the newly renamed
file like yourtablename.9203842903.thaoeu09gu023hgda3p.ext

No need to call store() directly as SQLFORM.factory will take care of
that for you.

I hope that this helps you.

David

On Oct 28, 10:38 am, Ross Peoples  wrote:
> Having a little trouble with getting an attachment to work. This is a
> simplified version of the controller:
>
> form = FORM('Attach', [INPUT(_name='attachment', _type='file')])
>
> if form.accepts(request):
>     v = form.vars.attachment
>     if not v is None and not v == '':
>         v = db.attachments.attachment.store(v)
>
>     db(db.attachments.id==id).update(attachment = v)
>
> And this is the result:
>
> Traceback (most recent call last):
>   File "/media/psf/Python/web2py/gluon/restricted.py", line 194, in restricted
>     exec ccode in environment
>   File "/media/psf/Python/web2py/applications/marlin/controllers/default.py" 
> , line 
> 586, in 
>   File "/media/psf/Python/web2py/gluon/globals.py", line 149, in 
>     self._caller = lambda f: f()
>   File "/media/psf/Python/web2py/applications/marlin/controllers/default.py" 
> , line 
> 471, in view_invite
>     v = db.rfq_item[field].store(v)
>   File "/media/psf/Python/web2py/gluon/dal.py", line 5557, in store
>     shutil.copyfileobj(file, dest_file)
>   File "/usr/lib/python2.6/shutil.py", line 27, in copyfileobj
>     buf = fsrc.read(length)
>   File "/usr/lib/python2.6/cgi.py", line 522, in __getattr__
>     raise AttributeError, name
> AttributeError: read
>
> The code for using store(v) came from another thread. When I print out v 
> before calling store(), it prints out something like this:
>
> FieldStorage('attachment', 'filename.txt', 'The actual text of the file')
>
> Looking through the dal.py, it looks like the line "shutil.copyfileobj(file, 
> dest_file)" is expecting an actual File object, not a FieldStorage object, 
> hence the attribute error. But if I try to pass "storage(v.file)" instead of 
> "storage(v)", then the DAL errors out because it's expecting a FieldStorage 
> object, not a File object.
>
> Is this a bug or am I doing something wrong here? I should mention that using 
> SQLFORM and SQLFORM.factory with attachments works just fine, it's only FORM 
> that is giving me trouble.


[web2py] How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread TheSweetlink
I have an app that polls for new messages and reloads a component when
there are new messages.

My problem is that when the component is refreshed/reloaded while a
user is typing, the message being typed disappears.

This makes sense because the component contains the form being
submitted.  For example refreshing the page before a form submission,
the refreshed page won't contain whatever was being typed.

I wish to retain the form data after the component is refreshed so
that the user can continue typing a message without having everything
blanked every time a new message appears.

What do you recommend as a method to keep what is being typed across a
component reload?

All I can think of right now is using web2py's ajax() to keep feeding
a session var whatever is being typed using JQuery's .change()

If there is anything in the session var, display it after the
component reload.  Upon form submission, clear the session var.

It just seems awfully inefficient to update a session var with the
ajax function for every character typed.

Can you suggest a smarter way of retaining the form's data after a
component reload?

Your help is most appreciated.

David


[web2py] Re: Auth in MongoDB

2011-10-28 Thread Francisco Costa
Hi Samuele, thanks for your answer.
Do you have any idea whats the status of the mongodb adapter
development?

> You will be able to do that using DAL with the mongodb adapter (once it
> is finished); you get that error since Auth() expects a DAL object as
> the second argument to constructor, in order to access the database;
> instead, you are passing a pymongo.Collection object that Auth doesn't
> know how to use..
>
> For now, the two solutions I see are:
> - temporarily use a sqlite database just to store users/auth stuff
> - write a custom (maybe inheriting) "MongoAuth" object that acts like
> Auth but uses mongodb collections to store data
>
> --
> Samuele ~redShadow~ Santi


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Ross Peoples
I was originally going to suggest checking for FieldStorage rather than 
StringIO, but wasn't sure if I wanted to suggest adding another import (of 
cgi).

[web2py] Caching a gluon.storage.Storage instance on GAE

2011-10-28 Thread pepper_bg
This one just hit me when I uploaded the app on GAE. No problems
whatsoever on the local development environment where I can pickle/
unpickle any Storage instance with Python 2.5.

The trace looks like:
Traceback (most recent call last):
  File "/base/data/home/apps/s~b-stock-staging/1.354286568593706431/
gluon/restricted.py", line 194, in restricted
exec ccode in environment
  File "/base/data/home/apps/s~b-stock-staging/1.354286568593706431/
applications/central/controllers/default.py:signup", line 153, in

  File "/base/data/home/apps/s~b-stock-staging/1.354286568593706431/
gluon/globals.py", line 149, in 
self._caller = lambda f: f()
  File "/base/data/home/apps/s~b-stock-staging/1.354286568593706431/
gluon/tools.py", line 2456, in f
return action(*a, **b)
  File "/base/data/home/apps/s~b-stock-staging/1.354286568593706431/
applications/central/controllers/default.py:signup", line 36, in
signup
  File "applications/central/modules/user_helpers.py", line 17, in
get_user_data
all_attributes =
attribute_helpers.BStockAttributes.get_attributes()
  File "applications/central/modules/attribute_helpers.py", line 18,
in get_attributes
return current.cache.ram('cached_attributes', lambda:
BStockAttributes._get_attributes(), time_expire = 6000)
  File "/base/data/home/apps/s~b-stock-staging/1.354286568593706431/
gluon/contrib/gae_memcache.py", line 39, in __call__
self.set(key, (time.time(), value))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/memcache/__init__.py", line 767, in set
namespace=namespace)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/memcache/__init__.py", line 872, in _set_with_policy
time, '', namespace)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/memcache/__init__.py", line 951, in _set_multi_async_with_policy
stored_value, flags = _validate_encode_value(value,
self._do_pickle)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/memcache/__init__.py", line 227, in _validate_encode_value
stored_value = do_pickle(value)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/
api/memcache/__init__.py", line 395, in _do_pickle
pickler.dump(value)
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py",
line 218, in dump
self.save(obj)
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py",
line 280, in save
f(self, obj) # Call unbound method with explicit self
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py",
line 542, in save_tuple
save(element)
  File "/base/python_runtime/python_dist/lib/python2.5/pickle.py",
line 300, in save
rv = reduce(self.proto)
TypeError: 'NoneType' object is not callable

The result of BStockAttributes._get_attributes() which I am trying to
cache are nested a couple of levels deep Storages:
http://test.com/staging/', 'logo_data': None, 'enabled': True,
'queue': None, 'do_not_market': False, 'attributes': , ... }>}>}>}>

The context where the exact error is raised looks like this:

File /base/python_runtime/python_dist/lib/python2.5/pickle.py in save
at line 300 code arguments variables

Function argument list:
(self=, obj=}>}>)

Code listing:

rv = reduce(obj)
else:
# Check for a __reduce_ex__ method, fall back to
__reduce__
reduce = getattr(obj, "__reduce_ex__", None)
if reduce:
rv = reduce(self.proto)   #
<---fails right here

else:
reduce = getattr(obj, "__reduce__", None)
if reduce:
rv = reduce()

Variables:
reduce: 
rv: undefined
self.proto: 2
self:   



I am aware that you can't pickle anything except Python native types,
lists, dicts, etc. but a Storage is basically a dict and I can't
replicate this on any other environment. GAE caches in memcache which
I also do in the dev. environment so not sure that is the issue
either. Anyone seen anything like this?

Appreciate your help...


Re: [web2py] Re: curious DAL timeout issue

2011-10-28 Thread Ovidio Marinho
One of the investigations would be to install postgres and see if it's the
samemistake, becauseI'm almost thinking that is a problem with mysql
relationships.



   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



2011/10/27 Richard Bruskiewich 

> Thank you Professor  Di Pierro for your direct reply.
>
> Since I am new to the community, I'm not sure how to log a ticket.
> I'll look into that but if you will bear with me, here is perhaps the
> additional information you are asking for:
>
> I've deployed Web2PY Version 1.98.2 (2011-08-04 00:47:09)
>
> The error is routinely reproducible... on four different web browsers
> (IE, FireFox, Chrome, Safari). Seems to be associated with starting a
> new session after an old session times out(?).  Refreshing the web
> browser clears the error, but the error always  recurs so is not
> pretty for end users visiting the site, generating the anonymous, in
> accessible Web2PY ticket URL which only Admin-privileged folks (i.e.
> me) can view over an SSH tunnel.
>
> I have web2py running behind NGINX via uswgi. This is installed on an
> Amazon EC2 server using web recipes (e.g.
> http://stackoverflow.com/questions/5335153/how-to-deply-web2py-using-nginx
> ,
> https://library.linode.com/web-servers/nginx/python-uwsgi/centos-5 and
> other helpful sites - I have deployment notes available, if they'd be
> needed).
>
> I don't seem to see this problem at all while running the app on my
> local machine (using the built in Rocket 1.2.2 server) only when in
> production deployment on the Amazon cloud.
>
> The back end database on the Amazon cloud is a remote MySQL image
> running at Amazon (RDS - http://aws.amazon.com/rds/). I suspect that
> mysql connections routinely time out in the cloud if they lay unused
> for some period of time. Not sure how this might trip up the web2py
> DAL.  You have the Traceback from my previous email (the same one
> occurs each time...). The Traceback isn't too informative as to
> exactly what part of my (model?) code is the one triggering the error.
> Is it the DAL class __init__? I could, I suppose, try to chase this
> down, but perhaps somebody more intimate with the code can better
> suggest where to look.
>
> Do let me know if any other information other than the above would be
> of use to troubleshooting the problem.
>
> I'll try to read up some more about Amazon RDS (and MySQL) to see if
> there is anything I can do to tweak the MySQL installation to mitigate
> timeouts.  Meanwhile, perhaps somebody out in the web2py community can
> comment.
>
> Thanks again for your direct reply.
>
> Cheers
> Richard Bruskiewich, PhD
> Scientific Consultant,
> International Rice Research Institute (IRRI)
>
> On Oct 27, 10:51 am, Massimo Di Pierro 
> wrote:
> > Which version? Is the problem reproducible? Can you tell us more?
> > Perhaps open a ticket
> >
> > On Oct 26, 11:24 am, RichardBruskiewich
> >
> >
> >
> >
> >
> >
> >
> >  wrote:
> > > I'm a recent fan of web2py, having adopted it for some major
> > > institutional projects in global agriculture. So far, so good - very
> > > happy - but I have a recurring curious low level database error which
> > > I'm not sure how to fix.
> >
> > > I've already tried trapping my web2py data model in a try... except
> > > block, inside a loop to retry the database connection (about 20 times,
> > > or so I think), but this doesn't seem to help.  The database
> > > connection often works... it is just that when the MySQL connection is
> > > idle for too long, or when a fresh connection is requested for a new
> > > user session, something fails... DAL doesn't handle it.
> >
> > > Here's the background: I'm running web2py in an NGINX server via uwsgi
> > > (which generally works fine - configured based on good advice online).
> > > However, this server runs within an Amazon Web Services (AWS) EC2
> > > server and accesses a MySQL instance running non-locally as a AWS
> > > Relational Database (RDB) server.
> >
> > > I'm using a DAL pool_size of 10.
> >
> > > Here's the error message:
> >
> > > Operational Error: (2013, 'Lost connection to MySQL server during
> > > query')
> >
> > > Traceback (most recent call last):
> > >   File "/opt/web2py/gluon/main.py", line 506, in wsgibase
> > > BaseAdapter.close_all_instances('commit')
> > >   File "/opt/web2py/gluon/dal.py", line 373, in close_all_instances
> > > getattr(instance,action)()
> > >   File "/opt/web2py/gluon/dal.py", line 1225, in commit
> > > return self.connection.commit()
> > >   File "/opt/web2py/gluon/contrib/pymysql/connections.py", line 562,
> > > in commit
> > > self.errorhandler(None, exc, value)
> > >   File "/opt/web2py/gluon/contrib/pymysql/connections.py", line 184,
> > > in defaulterrorhandler
> > > raise errorcla

[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Anthony
On Friday, October 28, 2011 12:37:04 PM UTC-4, Ross Peoples wrote:
>
> The list part was a typo, because the controller was just an example. I 
> found the original thread where I got the store() code from:
>
>
> https://groups.google.com/forum/#!searchin/web2py/manual$20upload/web2py/a5YanKxNbVU/99bxaB7A82IJ
>
> See Massimo's first reply.
>

Massimo made an error in his first reply (request.vars.image) and corrected 
it in his second reply (request.vars.image.file).
 

> Also see this thread, because this person seems to have the same problem, 
> but couldn't figure it out:
>
>
> https://groups.google.com/forum/#!searchin/web2py/manual$20upload/web2py/xmy5J6XaUuk/TWmZSo6SLUcJ
>

Yes, he made the same mistake, using request.vars.file (the FieldStorage 
object), instead of request.vars.file.file (the file object).
 

> As far as I can tell, nothing calls store(file). The only thing in web2py 
> that calls it, passes the filename in addition to the file. And since you 
> cannot make store() work at all without giving it a filename...
>

store() works without passing it a filename -- if no filename is provided, 
it uses file.name as the filename.

Anyway, it might not be a bad idea to let store() take a FieldStorage 
object, though maybe with code that specifically checks for FieldStorage 
(this would replace lines 3-4 of the current function):

if isinstance(file, cgi.FieldStorage):
file = file.file
filename = filename or file.filename
elif not filename:
filename = file.name

Anthony


[web2py] Re: book version 3.1 online

2011-10-28 Thread mikech
Is there somewhere that lists the diff between the most current and prior 
versions?  

[web2py] CSS for book printing

2011-10-28 Thread ~redShadow~
I just wrote a small CSS that changes a bit the layout of the web2py
book in order to make it more printer-friendly.

I tested it using Stylish Firefox addon, and PDF generated by print to
pdf looks nice.

I'm attaching two versions of the CSS:

web2py_book_stylish.css
  is the one I used with Stylish Firefox addon.
  All the ``!important`` are needed since for some reason Stylish CSS
  don't take the precedence over the "real ones".

web2py_book_print.css
  is the version ready to be included among the other CSS of the site,
  in order to directly allow pretty-printing (if you wish to).

-- 
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

/**
  CSS For printer-friendly version of http://www.web2py.com/book
  This version is to be used with Stylish Firefox addon
**/
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("www.web2py.com") {
body, #outer, #container {background:transparent !important;}
#container {border:none !important;}
#outer {width: 100% !important;}
#header .quote {display:none;}
#sidebar{display:none !important;}
.article{width:100% !important;}
.credits select {display:none;}
}

/**
  CSS For printer-friendly version of http://www.web2py.com/book
**/
@media print {
body, #outer, #container {background:transparent;}
#container {border:none;}
#outer {width: 100%;}
#header .quote {display:none;}
#sidebar {display:none;}
.article {width:100%;}
.credits select {display:none;}
}



signature.asc
Description: This is a digitally signed message part


[web2py] Re: list of usernames

2011-10-28 Thread Archibald Linx
Thank you Anthony, I have given it a thought and I will create another
table called "status".

The "message" table contains the fields : "id" and "to" among others.
The "status" table contains the fields : "id", "message_id", "person"
and "status" among others.
"to" is readable and writable.
"message_id", "person" and "status" are non readable and non writable
fields.

I think that what I need is one form for multiple tables :
http://web2py.com/book/default/chapter/07#One-form-for-multiple-tables

Here are two rows of the "message" table (without all the fields) :
id / to
1  / steve,jimmy
2  / julia

Here are the corresponding rows of the "status" table (without all the
fields) :
id / message_id / person / status
1  /   1/ steve  /  0
2  /   1/ jimmy  /  0
3  /   2/ julia  /  0

The "message_id" field in the "status" table refers to the "id" in the
"message" table.

Here is what I have tried in the controller :

form = SQLFORM.factory(db.message,db.status)
 if form.process().accepted:
id = db.message.insert(**db.message._filter_fields(form.vars))
form.vars.message_id = id
for to in form.vars.to:
form.vars.person = to
id =
db.status.insert(**db.status._filter_fields(form.vars))

Unfortunately the "to" field of the "message" table remains empty. And
an empty row is inserted in the "status" table.

Where does the problem come from ? Could there be a problem with the
"_filter_fields" method when it deals with a "list:reference" field ?
I am just giving it a go ;)

Thanks a lot,
Archibald


On 26 oct, 23:57, Anthony  wrote:
> That's what I was thinking. list: type fields are good if you just need to
> store a list of things associated with a given record and retrieve the list
> when the record is retrieved, but they aren't necessarily easy or efficient
> for querying the data (depending on the application). If you really want to
> stick with the list: fields, I suppose you could do a select to get the
> Julia records, and then use some Python code to further filter the records
> based on status. You might also be able to create either a computed or
> virtual field that concatenates name and status into a new list, and query
> that. Depending on how many records you're dealing with, though, it might
> be more efficient to go with a more normalized data structure.
>
> Anthony
>
>
>
> On Wednesday, October 26, 2011 5:38:41 PM UTC-4, Archibald Linx wrote:
>
> > Dear Anthony,
>
> > I have asked the question on Stackoverflow and it seems it is a bad
> > database structure ;) Sorry.
>
> > See :http://stackoverflow.com/questions/7908024/sql-query-list-fields
>
> > I will put the status information somewhere else. Maybe in a separate
> > database. I don't know yet.
>
> > Thanks for the help you gave me,
> > Archibald
>
> > On 26 oct, 20:35, Archibald Linx  wrote:
> > > Thank you Anthony.
>
> > > I don't know about the raw SQL query. I will ask on Stackoverflow and
> > > post the link here.
>
> > > Best,
> > > Archibald
>
> > > On 26 oct, 19:07, Anthony  wrote:
>
> > > > On Wednesday, October 26, 2011 12:21:33 PM UTC-4, Archibald Linx
> > wrote:
>
> > > > > Thank you Anthony !
>
> > > > > Is the length "len" always defined in Python ?
>
> > > > No, I think the len() function will fail if you pass None to it, so if
> > you
> > > > were using request.vars, you'd want something like:
>
> > > > default=len(request.vars.to) if request.vars.to is not None else
> > [whatever
> > > > you want the default to be otherwise]
>
> > > > > I couldn't find much tools in the documentation to query lists of
> > > > > references apart from the "contains" operator.
>
> > > > > For example, let's have the following "message" table :
> > > > > id / to          / status
> > > > > 1  / steve,jimmy / 0,2
> > > > > 2  / john,julia  / 1,2
> > > > > 3  / julia,peggy / 0,1
>
> > > > > I want to get the rows where "Julia" is in "to" and where her status
> > > > > is "0" (in this particular case, that is row n°3).
> > > > > With the "contains" operator I only know how to get the rows where
> > > > > "Julia" is in "to" (that is row n°2 and n°3).
>
> > > > > Should I write raw SQL ?
>
> > > > How would you write it in raw SQL?- Masquer le texte des messages 
> > > > précédents -
>
> - Afficher le texte des messages précédents -


[web2py] Re: Specifying Field Focus

2011-10-28 Thread horridohobbyist
I tried this, replacing the document.forms[0].elements[0].focus()
line. It didn't work.

Thanks,
Richard

On Oct 28, 10:11 am, Richard G  wrote:

>  Or if you don't have much info on the page and just want the first visible
> field to have focus you could do:
> $("input:visible:enabled:first").focus()


Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-28 Thread Hong-Khoan Quach
Hi,

I think that depends on Massimo. I sent him the patch yesterday, I
think. So Massimo, maybe you can say something about that?

Of course I can also send the patch to you, thodoris, so that you
can also test whether the bug is fixed.

Regards

Hong-Khoan

Am 28.10.2011 17:47, schrieb thodoris:
> Hi, i have come across the same problem. Do you have any idea when will
> the patch be included in a realease?



signature.asc
Description: OpenPGP digital signature


Re: [web2py] PowerGrid x PowerTable

2011-10-28 Thread Bruno Rocha
if you want a solid and updated solution use SQLFORM.grid or
SQLFORM.smartgrid

if you need more flexibility on client side, templates and a grid based in
ajax with JSON use PowerGrid.

I am not updating PowerTable, it needs to be completelly rewriten.

if someone wants to addopt it the code is in my bitbucket.

http://zerp.ly/rochacbruno
Em 28/10/2011 11:03, "Ovidio Marinho"  escreveu:

> Estava pensando em usar um grid e fiquei na duvida PowerGrid ou PowerTable,
> quando usar um ou outro? e quais suas diferenças particulares?
>
> I was thinking of using a grid and I was in doubt or PowerTable PowerGrid
> , when using one or the other? and what their particular differences?
>
>
>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
>
>


[web2py] Re: A helper and icon

2011-10-28 Thread annet
Hi Anthony,

Thanks, problem solved:



  
Home
Lesrooster
  
 


Kind regards


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Ross Peoples
The list part was a typo, because the controller was just an example. I 
found the original thread where I got the store() code from:

https://groups.google.com/forum/#!searchin/web2py/manual$20upload/web2py/a5YanKxNbVU/99bxaB7A82IJ

See Massimo's first reply. Also see this thread, because this person seems 
to have the same problem, but couldn't figure it out:

https://groups.google.com/forum/#!searchin/web2py/manual$20upload/web2py/xmy5J6XaUuk/TWmZSo6SLUcJ

As far as I can tell, nothing calls store(file). The only thing in web2py 
that calls it, passes the filename in addition to the file. And since you 
cannot make store() work at all without giving it a filename, then we 
should either make filename a required parameter, or fix the DAL as 
suggested above.


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Anthony
On Friday, October 28, 2011 12:07:08 PM UTC-4, Anthony wrote:
>
> On Friday, October 28, 2011 10:57:05 AM UTC-4, Ross Peoples wrote:
>>
>> I'm starting to think this is a bug since SQLFORM calls store() like this:
>>
>> store(f.file, f.filename)
>>
>> I could do the same thing in my code, but the documentation I've seen so 
>> far only requires you to pass one parameter to store().
>>
>
> I think this is the only place in the book that mentions store(), and it 
> passes the file (stream) and filename: 
> http://web2py.com/book/default/chapter/06#Manual-Uploads.
>

Note, the filename is optional, but should be provided because store() uses 
it to get the correct extension for the file (and encodes the original 
filename into the new name for later decoding when retrieved).

Anthony 


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Anthony
On Friday, October 28, 2011 10:57:05 AM UTC-4, Ross Peoples wrote:
>
> I'm starting to think this is a bug since SQLFORM calls store() like this:
>
> store(f.file, f.filename)
>
> I could do the same thing in my code, but the documentation I've seen so 
> far only requires you to pass one parameter to store().
>

I think this is the only place in the book that mentions store(), and it 
passes the file (stream) and filename: 
http://web2py.com/book/default/chapter/06#Manual-Uploads.

Anthony


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Anthony
On Friday, October 28, 2011 10:38:10 AM UTC-4, Ross Peoples wrote:
>
> Having a little trouble with getting an attachment to work. This is a 
> simplified version of the controller:
>
> form = FORM('Attach', [INPUT(_name='attachment', _type='file')])
>

Is the above a typo? INPUT should either not be in a list, or the list 
should be preceded by a *. Also, don't you need a submit button?
 

>
> if form.accepts(request):
> v = form.vars.attachment
> if not v is None and not v == '':
> v = db.attachments.attachment.store(v)
>

v = db.attachments.attachment.store(v.file, v.filename) works for me.
 

> Looking through the dal.py, it looks like the line "shutil.copyfileobj(file, 
> dest_file)" is expecting an actual File object, not a FieldStorage object, 
> hence the attribute error. But if I try to pass "storage(v.file)" instead of 
> "storage(v)", then the DAL errors out because it's expecting a FieldStorage 
> object, not a File object.
>
>
Looks like Field.store() is expecting a file object, not a FieldStorage 
(the only place it does anything with 'file' is when calling 
shutil.copyfileobj).
 


[web2py] Re: Web2py won't connect to MSSQL

2011-10-28 Thread Omi Chiba
Massimo, Chris

Thank you both of your reply!

I added import pyodbc in db.py and here's what I get. This is expected just 
like Chris described.

"ImportError: DLL load failed: A dynamic link library (DLL) initialization 
routine failed."

Then I tried mt.exe things. (See attached file) 
Strangely, I got error with python27.dll but went through with python.exe. 
At least, I confirmed the modified date has been changed on the .pyd files. 
But I still have the same problem...maybe I'm unlucky one :(

Chris,
Can you send me the fixed .pyd files so I can try in my environment ? 






?c:\Program Files\Microsoft SDKs\Windows\v7.0A\bin>mt.exe 
-inputresource:C:\Windows\System32\python27.dll -outputresource
:C:\Python27\Lib\site-packages\pyodbc.pyd
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

mt.exe : general error c101008c: Failed to read the manifest from the resource 
of file "C:\Windows\System32\python27.dll
". The specified resource name cannot be found in the image file.

c:\Program Files\Microsoft SDKs\Windows\v7.0A\bin>mt.exe 
-inputresource:C:\Python27\python.exe  -outputresource:C:\Pytho
n27\Lib\site-packages\pyodbc.pyd
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

c:\Program Files\Microsoft SDKs\Windows\v7.0A\bin>mt.exe 
-inputresource:C:\Python27\python.exe  -outputresource:C:\Pytho
n27\Lib\site-packages\pyodbcconf.pyd
Microsoft (R) Manifest Tool version 5.2.3790.2076
Copyright (c) Microsoft Corporation 2005.
All rights reserved.

c:\Program Files\Microsoft SDKs\Windows\v7.0A\bin>^V

[web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-28 Thread thodoris
Hi, i have come across the same problem. Do you have any idea when will the 
patch be included in a realease?


[web2py] Re: Exceeding memory limits in webfaction

2011-10-28 Thread Jose
After creating the Symbolic link I have not had any problems. I hope
that continues.

thanks annet

Jose


Re: [web2py] unicode support for args

2011-10-28 Thread Jonathan Lundell
On Oct 25, 2011, at 11:26 PM, Pawel Jasinski wrote:

> On Oct 26, 5:25 am, Jonathan Lundell  wrote:
>> On Oct 25, 2011, at 2:06 PM, Pawel Jasinski wrote:
>> 
>>> hi,
>> 
>>> thanks! That solved my ~ problem.
>> 
>>> Unfortunately for my öäü (chars above 128 and below 255 in latin-1) I
>>> still need to overcome 2 challenges:
>> 
>>> 1. re.U must be supplied to compile or match to take advantage of
>>> unicode interpretation of \w.
>>> I could shift compile into the routes.py. Is it acceptable?
>> 
>> I think so, yes.
>> 
>> 
>> 
>>> 2. at some point before match call args have to be subjected to
>>> decode('utf-8') to become unicode
>>> Any suggestions?
>> 
>> I'd like to do this right, but I'm a little confused. Do we need to consider 
>> Punycode, for example? Or is that just for domain names?
>> 
> 
> what I mean is very trivial:

Thanks. 

I'm a little concerned, for compatibility reasons, about making an 
unconditional change. I'm thinking I'll put an enable flag into the routing 
parameters and then implement both changes you suggest (vars, too), conditional 
on that flag.

I'm traveling now and am not likely to get to it for about a week, though.

> 
> ***
> *** 915,925 
>  def validate_args(self):
>  '''
>  check args against validation pattern
>  '''
>  for arg in self.args:
> ! if not self.router._args_match.match(arg):
>  raise HTTP(400, thread.routes.error_message %
> 'invalid request',
> web2py_error='invalid arg <%s>' % arg)
> 
>  def update_request(self):
>  '''
> --- 939,949 
>  def validate_args(self):
>  '''
>  check args against validation pattern
>  '''
>  for arg in self.args:
> ! if not
> self.router._args_match.match(unicode(arg,'utf-8')):
>  raise HTTP(400, thread.routes.error_message %
> 'invalid request',
> web2py_error='invalid arg <%s>' % arg)
> 
> This makes the validation pass. The args are still passed down to
> application as char and have to be again converted there into Unicode.
> Ideally framework should make it happen once.
> 
>> 
>> 
>>> --Pawel
>> 
>>> On Oct 25, 9:18 pm, Jonathan Lundell  wrote:
 On Oct 25, 2011, at 11:57 AM, Pawel Jasinski  
 wrote:
>> 
> hi,
>> 
>> of directory traversal attacks (~ specifically).
> how exactly?
>> 
> I am talking about arguments and only arguments.
> I agree that ~ in case of application/controller/method makes no sense
> In case of static agree 100%, but that is different control path.
>> 
 If you enable the parametric router, you'll get the kind of args handling 
 you want, with the added feature that you can rewrite the args validation 
 regex.
>> 
> The arguments are just that, arguments. If you put such a blanket
> statement about arguments in url, should you also do it for forms? At
> the end these are also arguments and someone may take it 1:1 and feed
> into 'open'.
> It is up to the controller to decide what to do with args. I believe
> nobody takes anything what comes from browser (args or form elements)
> and try to use it as argument of the 'open'. In case of web2py, DAL
> delivers already a perfect mechanism to take whatever comes and
> convert into reasonable name:
> filename=db.table.field.store(content,whatever_convoluted_name_we_get).
>> 
> To be specific about the args filtering:
>> 
> agrs must match:
> regex_args = re.compile(r'''
> (^
> (?P
> ( [\w@/-][=.]? )*  # s=args
> )?
> /?$)# trailing slash
> ''', re.X)
>> 
> what I suggest is:
> regex_args = re.compile(r'''
> (^
> (?P
> ( [~\w@/-][=.]? )*  # s=args
> )?
> /?$)# trailing slash
> ''', re.X|re.U)
>> 
> Cheers,
> Pawel




Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-28 Thread szimszon
Tnx,


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread Ross Peoples
I'm starting to think this is a bug since SQLFORM calls store() like this:

store(f.file, f.filename)

I could do the same thing in my code, but the documentation I've seen so 
far only requires you to pass one parameter to store(). So, if the DAL was 
changed to look something like this (starting at at line ):

dest_file = open(pathfilename, 'wb')
try:
if isinstance(file, cString.StringIO):
shutil.copyfileobj(file, dest_file)
else:
shutil.copyfileobj(file.file, dest_file)
finally:
dest_file.close()

That would probably solve the problem.


Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-28 Thread Hong-Khoan Quach
Hi,

I sent you the patch as a pm since I don't know whether it is ok to post
the patch here.

Regards

Hong-Khoan

Am 28.10.2011 09:01, schrieb szimszon:
> Hi!
> 
> Could you please post the patch here or pm me I need it as fast as
> possible :-o
> 
> Tnx.



signature.asc
Description: OpenPGP digital signature


[web2py] Manual Upload with FORM

2011-10-28 Thread Ross Peoples
Having a little trouble with getting an attachment to work. This is a 
simplified version of the controller:

form = FORM('Attach', [INPUT(_name='attachment', _type='file')])

if form.accepts(request):
v = form.vars.attachment
if not v is None and not v == '':
v = db.attachments.attachment.store(v)

db(db.attachments.id==id).update(attachment = v)

And this is the result:

Traceback (most recent call last):
  File "/media/psf/Python/web2py/gluon/restricted.py", line 194, in restricted
exec ccode in environment
  File "/media/psf/Python/web2py/applications/marlin/controllers/default.py" 
, line 
586, in 
  File "/media/psf/Python/web2py/gluon/globals.py", line 149, in 
self._caller = lambda f: f()
  File "/media/psf/Python/web2py/applications/marlin/controllers/default.py" 
, line 
471, in view_invite
v = db.rfq_item[field].store(v)
  File "/media/psf/Python/web2py/gluon/dal.py", line 5557, in store
shutil.copyfileobj(file, dest_file)
  File "/usr/lib/python2.6/shutil.py", line 27, in copyfileobj
buf = fsrc.read(length)
  File "/usr/lib/python2.6/cgi.py", line 522, in __getattr__
raise AttributeError, name
AttributeError: read

The code for using store(v) came from another thread. When I print out v before 
calling store(), it prints out something like this:

FieldStorage('attachment', 'filename.txt', 'The actual text of the file')


Looking through the dal.py, it looks like the line "shutil.copyfileobj(file, 
dest_file)" is expecting an actual File object, not a FieldStorage object, 
hence the attribute error. But if I try to pass "storage(v.file)" instead of 
"storage(v)", then the DAL errors out because it's expecting a FieldStorage 
object, not a File object.


Is this a bug or am I doing something wrong here? I should mention that using 
SQLFORM and SQLFORM.factory with attachments works just fine, it's only FORM 
that is giving me trouble.



[web2py] Re: Specifying Field Focus

2011-10-28 Thread Richard G
You could also use jquery syntax:
$('#item' :input:visible:enabled:first).focus()
 Or if you don't have much info on the page and just want the first visible 
field to have focus you could do:
$("input:visible:enabled:first").focus()

More info on the jquery selectors is at: 
http://docs.jquery.com/DOM/Traversing/Selectors


[web2py] Re: Specifying Field Focus

2011-10-28 Thread Anthony
Use jQuery -- it's a lot easier to find particular elements within the DOM.

http://api.jquery.com/focus/

On Friday, October 28, 2011 9:51:36 AM UTC-4, horridohobbyist wrote:
>
> Problem sol-ved... 
>
>  
> document.forms[0].elements[0].focus(); 
>  
>
> Richard 
>
> On Oct 28, 7:13 am, horridohobbyist  wrote: 
> > I've searched the archive and have found several solutions for 
> > specifying field focus using JavaScript, but they all seem to be out 
> > of date, ie, they don't work. What is the current accepted method of 
> > specifying field focus? I have a form with a text area field named 
> > "message". Something like: 
> > 
> >  
> > document.form.message.focus() 
> >  
> > 
> > ...should work. 
> > 
> > Thanks, 
> > Richard



Re: [web2py] Suggestions for multiple files upload in form

2011-10-28 Thread Paolo Caruccio
Ovidio thank you for your consideration.

In fact, I have not given much attention to the results grid because the 
goal of my work was to create a control for uploading multiple files.
In addition, the visual aspect is only demonstration. The essential css 
rules are on the top of multiuploads.css (before /* CUSTOMIZATION */ 
comment).
However, I am preparing a packed .w2p web2py small application as required 
by Bruno.
Maybe, there you will see something nicer.

Ciao.

Paolo


[web2py] Re: Specifying Field Focus

2011-10-28 Thread horridohobbyist
Problem sol-ved...


document.forms[0].elements[0].focus();


Richard

On Oct 28, 7:13 am, horridohobbyist  wrote:
> I've searched the archive and have found several solutions for
> specifying field focus using JavaScript, but they all seem to be out
> of date, ie, they don't work. What is the current accepted method of
> specifying field focus? I have a form with a text area field named
> "message". Something like:
>
> 
> document.form.message.focus()
> 
>
> ...should work.
>
> Thanks,
> Richard


[web2py] Re: SQLFORM.grid behavior with an empty table

2011-10-28 Thread apple
This is fixed in trunk.

On Oct 28, 1:44 am, Bob St John  wrote:
> using 1.99.2
>
> SQLFORM.grid...
>
> I don't see the need for this statement...
>
> line 1641: if not searchable and not rows: return DIV(T('No records
> found'))
>
> If it was removed a user would see an empty grid rather than just a
> div, no matter what the value of 'searchable' was.
>
> An empty grid allows the user to add a record, which seems more usable
> than the 'No records found' result when searchable=False


[web2py] Re: SQLFORM.grid behavior with an empty table

2011-10-28 Thread Cliff
I think an Add button by itself would look better, maybe with the same
background as the search header.

On Oct 27, 8:44 pm, Bob St John  wrote:
> using 1.99.2
>
> SQLFORM.grid...
>
> I don't see the need for this statement...
>
> line 1641: if not searchable and not rows: return DIV(T('No records
> found'))
>
> If it was removed a user would see an empty grid rather than just a
> div, no matter what the value of 'searchable' was.
>
> An empty grid allows the user to add a record, which seems more usable
> than the 'No records found' result when searchable=False


[web2py] PowerGrid x PowerTable

2011-10-28 Thread Ovidio Marinho
Estava pensando em usar um grid e fiquei na duvida PowerGrid ou PowerTable,
quando usar um ou outro? e quais suas diferenças particulares?

I was thinking of using a grid and I was in doubt or PowerTable PowerGrid, when
using one or the other? and what their particular differences?


   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


Re: [web2py] crud update problem with 1.99.2?

2011-10-28 Thread Richard Vézina
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" 
> , 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" 
> , 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 
> .vars.membid]
>  db.Members.Email.comment = A 
> ('Add/Edit/Delete Email 
> Address(es)',
>  _href=URL 
> ('memberemail', 
> vars=dict(membid=request 
> .vars.membid, 
> next=request .vars.next)))
>  db.Members.Affiliation.comment = A 
> ('Add/Edit/Delete 
> Affiliation(s)',
>  _href=URL 
> ('memberaffiliation', 
> vars=dict(membid=request 
> .vars.membid, 
> next=request .vars.next)))
>  if member.Status in ('Full', 'Student'):
>  db.Members.Paiddate.comment = A 
> ('Process dues payment',
>  _href=URL 
> ('memberdues', 
> vars=dict(membid=request 
> .vars.membid, 
> next=request .vars.next)))
>  else:
>  db.Members.Paiddate.comment = 'Only for Full & Student Members'
>  next = URL 
> ('memberform', 
> vars=dict(membid=request 
> .vars.membid, 
> next=request .vars.next))
>  form = crud.update(db.Members, request 
> .vars.membid,
>  deletable = False, next=next, onvalidation=setmodified)
>  form[0][-1][1].append(INPUT 
> (_type="button",_value="Cancel",
>  _onclick="window.location='%s';"%request 
> .vars.next))
>  else:
>  db.Members.Email.comment = 'Add email address(es) after creating basic 
> record'
>  db.Members.Affiliation.comment = 'Add affiliation(s) after creating 
> basic record'
>  db.Members.Paiddate.comment = 'Usually set by processing dues payment'
>  form = crud.create(db.Members, next=request 
> .vars.next, 
> onaccept=newmember)
>  form[0][-1][1].append(INPUT 
> (_type="button",_value="Cancel",
>  _onclick="window.location='%s';"%request 
> .vars.next))
>  return dict(form=form, next=request 
> .vars.next, 
> membid=request 
> .vars.membid)
>
>
>


[web2py] Re: A helper and icon

2011-10-28 Thread Anthony
A(_onclick='web2py_component("%s","component")' % 
URL('locator','imagetext.load',args=company.id), ...)

On Friday, October 28, 2011 5:55:14 AM UTC-4, annet wrote:
>
> Is there a way in web2py to generate the following element: 
>
>  283","component");return false;" href="/init/locator/imagetext.load/ 
> 283"> Home 
>
> using the A helper: 
> {{=A('Home',_href=URL('locator','imagetext.load',args=[company.id]),cid='component')}}
>  
>
>
>
> This is part of an icon menu: 
>
>  
>
>  id="home">{{=A('Home',_href=URL('locator','imagetext.load',args=[
> company.id]),cid='component')}} 
>  
> 
> id="timetable">{{=A('Lesrooster',_href=URL('timetable','timetable.load',args=[
> company.id]),cid='component')}} 
>  
>
>   
>
> I would like every  element to have an icon + text, the icon 
> being set in a css file: 
>
> .icon_menu ul  li a span { 
> background-image: url("/init/static/images/home.png"); 
> } 
>
>
> Kind regards, 
>
> Annet



[web2py] Re: curl post with authentication

2011-10-28 Thread szimszon
Could be related: https://groups.google.com/forum/#!topic/web2py/lLCCUrwB5x0


[web2py] The -f command line switch seems to break custom_import

2011-10-28 Thread pgergo
Hi!

I started to use the debian version of web2py, which comes with an
executable '/usr/bin/web2py'. It was run from a custom directory under
'/home/web2py'. This script gets the current directory, and adds it to
the command line with a '-f' switch, and chdir-s into '/usr/share/
web2py'. This worked fine at first.

But then I added a custom module under 'applications/myapp/modules'.
Had '__init__.py'-s everywhere. But the module couldn't be imported
from a controller using the 'import mymodule' syntax. The 'mymodule =
local_import("mymodule")' works, though. So I started some
investigation.

It seems that the import mechanism is implemented in the
'custom_import.py' by calling 'custom_import_install(web2py_path)'.
But its argument is always '/usr/share/web2py', so when later checking
the importing file's name in '_matchAppDir', it concludes that it is
not under that directory, and skips the importing magic. The
application is not there, it is under '/home/web2py', as specified
with the '-f' switch. The 'custom_import_install' is called in
'main.py' during module load, while the command line is only checked
in the HttpServer constructor. So the custom import mechanism ignores
the command line switch, and all files under the specified directory.

Am I correct on this one?


[web2py] curl post with authentication

2011-10-28 Thread thodoris
Hi,

I have this simple configuration:

db.define_table( 'files',
Field('file','upload'))

@auth.requires_login()
def upload():
db.files.id.default = request.args(0)
form = crud.create(db.files)
return dict(form=form)

If i remove authentication from upload() i can upload a file using
curl. But i would like apply the authentication restriction. So i
register a user with username: t...@nowhere.com and password: and
i try the following command

curl --verbose -u t...@nowhere.com: -F "file=@/home/thodoris/
Downloads/test.rtp" -F "_formname=files/None"  
http://127.0.0.1:8000/test/default/upload

and i get the following error message:

* About to connect() to 127.0.0.1 port 8000 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
* Server auth using Basic with user 't...@nowhere.com'
> POST /test/default/upload HTTP/1.1
> Authorization: Basic dGVzdEBub3doZXJlLmNvbToxMTEx
> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o 
> zlib/1.2.3.4 libidn/1.18
> Host: 127.0.0.1:8000
> Accept: */*
> Content-Length: 3187083
> Expect: 100-continue
> Content-Type: multipart/form-data; 
> boundary=69a14296aa8c
>
< HTTP/1.1 100 Continue
< HTTP/1.1 303 SEE OTHER
< Set-Cookie:  session_id_test=127.0.0.1-0054c564-830d-4fe4-
ae3d-924a1ba931b8; Path=/
< Content-Type: text/html; charset=UTF-8
* Avoided giant realloc for header (max is 102400)!
* Closing connection #0
curl: (27) Avoided giant realloc for header (max is 102400)!

Could anyone help me understand what the problem is and how to solve
it?

I have also tried setting

auth.settings.allow_basic_login=True in the models but still the same.


[web2py] Re: New questions about the book

2011-10-28 Thread Archibald Linx
Thank you very much Anthony.

I have read Chapter 7 up to the "Hidden Fields" section and it is
already more clear in my head.

Archibald


On 28 oct, 02:12, Anthony  wrote:
> On Thursday, October 27, 2011 7:57:31 PM UTC-4, Archibald Linx wrote:
>
> > 1) Sometimes I see in the documentation "if form.process().accepted:"
> > and sometimes "if form.accepts(request.vars, session):". What's the
> > difference between the two ?
>
> form.process() was added very recently and is now preferred over
> form.accepts (though the latter is still perfectly fine).
> Seehttp://web2py.com/book/default/chapter/07#The-process-and-validate-me
> form.process() does the same thing (it actually calls form.accepts()), but
> returns the form itself (hence the need to add .accepted if you want to see
> if it was accepted).
>
>
>
> > 2) On page 109 (
> >http://www.web2py.com/book/default/chapter/03#An-Image-Blog
> > ), I have not really understood the following sentence :
>
> > "Line 9 processes the submitted form (the submitted form variables are
> > in request.vars) within the current session (the session is used to
> > prevent double submissions, and to enforce navigation)."
>
> > Line 9 refers to : "form.accepts(request.vars, session):"
>
> > Would it be different if I would just write :
> > "form.accepts(request.vars):" ?
>
> Yes, if you leave out the session, it won't create a hidden _formkey field
> and store the value in the session. This is the mechanism web2py uses to
> prevent double form submission and CSRF attacks.
> Seehttp://web2py.com/book/default/chapter/07#Hidden-fields.
>
>
>
>
>
>
>
>
>
> > 3) On page 108 (
> >http://www.web2py.com/book/default/chapter/03#An-Image-Blog
> > ), there is written  :
>
> > if form.process().accepted:
> >     response.flash = 'your comment is posted'
>
> > On page 112 (http://www.web2py.com/book/default/chapter/03#Adding-CRUD
> > ), there is written :
>
> > form = SQLFORM(table)
> > if form.process().accepted:
> >     session.flash = '...'
>
> > Why is it sometimes "response.flash" and sometimes "session.flash" ?
>
> response.flash if the form page will be reloading; session.flash if you are
> redirecting to a new page.
> Seehttp://web2py.com/book/default/chapter/07#Forms-and-redirection.
>
> Basically, things should hopefully clear up when you read the forms chapter.
>
> Anthony


[web2py] Web2py + Sencha Ext Designer

2011-10-28 Thread António Ramos
Hello, is it a good thinking to use Ext Designer for the ui and web2py for
the background BI?

Other alternatives for Rapid App Devel.?


[web2py] Specifying Field Focus

2011-10-28 Thread horridohobbyist
I've searched the archive and have found several solutions for
specifying field focus using JavaScript, but they all seem to be out
of date, ie, they don't work. What is the current accepted method of
specifying field focus? I have a form with a text area field named
"message". Something like:


document.form.message.focus()


...should work.

Thanks,
Richard


[web2py] A helper and icon

2011-10-28 Thread annet
Is there a way in web2py to generate the following element:

 Home

using the A helper:
{{=A('Home',_href=URL('locator','imagetext.load',args=[company.id]),cid='component')}}


This is part of an icon menu:


  
{{=A('Home',_href=URL('locator','imagetext.load',args=[company.id]),cid='component')}}

{{=A('Lesrooster',_href=URL('timetable','timetable.load',args=[company.id]),cid='component')}}

  
 

I would like every  element to have an icon + text, the icon
being set in a css file:

.icon_menu ul  li a span {
background-image: url("/init/static/images/home.png");
}


Kind regards,

Annet


[web2py] sqlform.grid and represent vs. format

2011-10-28 Thread szimszon
I have to tables

db.define_table( 'wdirs',
Field( 'name', type = 'string',
requires = IS_NOT_EMPTY()),
*(a)* *format='%(name)s %(id)s'*
)

db.define_table( 'files',
Field( 'wdirs_id', db.wdirs,
requires = IS_IN_DB( db, db.wdirs.id, "%(name)s %(id)s" 
),
*(b)* *represent = lambda id, row: row.wdirs_id.name*)
)

If I remove *(b)* than the SQLFORM.grid(db.files) displays only the record 
id in wdirs_id column. The wdirs' table format parameter isn't honored. I 
have to make the represent to be able to display the name of the wdir not 
only the record id.

Am I right or I miss something?


Re: [web2py] Re: Found a bug: XMLRPC with basic authorization fails

2011-10-28 Thread szimszon
Hi!

Could you please post the patch here or pm me I need it as fast as possible 
:-o

Tnx.