[web2py] Re: Form submission and "view page source"

2012-06-29 Thread Neil


>
> It shouldn't happen "randomly". It should only happen when you open the 
> same page (or any page with a form that has the same formname) in the same 
> browser, and then go back to the original page and try to submit the 
> original form. We've talked about allowing multiple versions of the 
> _formkey for the same form to avoid this problem, but that hasn't been 
> implemented yet.
>

Thanks - this has been very useful. It is definitely happening for me 
without opening a new page/tab in the browser, but is very inconsistent. A 
bit more information: my site guides the user from one page to the next, 
but occasionally loops back on itself to an earlier page, depending on user 
input. This problem seems to occur (inconsistently) when revisiting pages 
they've already been to. I suppose there is some sort of conflict with the 
_formname. Assigning a unique formname should do the trick.

Thanks again,
Neil


[web2py] Re: import modules

2012-06-29 Thread Corne Dickens
It depends on what you do..

Just installing with PIP or easy_install works..
Installing in web2py/site_packages and before starting web2py add 
site_packages to the python path also works.

But in web2py its self the site_packages is added to the path, but in that 
case installed packages are not (or not all of them) recognized.
Difference is that in case you put a module in site-packages yourself you 
get a directory 'yourmodule'
With easy_install / pip you get yourmodule.egg with yourmodule as a subdir.



Op donderdag 28 juni 2012 16:55:35 UTC+2 schreef Niphlod het volgende:
>
> Ahem
> If I install a module using easy_install web2py recognizes it 
> correctly (you should use pip, btw)
>
> Maybe you are running two different python version and the easy_installed 
> library is on one interpreter and you run web2py with another 
> interpreter..
>
> Web2py first looks into modules/ of the application folder, than into 
> site-packages/ of web2py folder and then in normal interpreter paths.
> so, if you can:
>
> >> python
> >> import this
>
> you can also
>
> >>python web2py.py
>
> and call "import this" in your apps.
>
>
> Il giorno giovedì 28 giugno 2012 16:27:58 UTC+2, Corne Dickens ha scritto:
>>
>> Hi,
>>
>> Web2py imports modules from the site-packages directory which is a great 
>> way to build a project withoud any 'external' dependencies.
>> Only it does not work with modules installed by python easy-install.
>>
>> Python it's self uses a site module for this, which can be added to 
>> web2py in an easy way.
>> Maybe this is a nice addition for the next version?
>>
>> --- web2py/gluon/admin.py   2012-03-04 23:11:41.0 +0100
>> +++ ../web2py/gluon/admin.py2012-03-08 12:19:52.0 +0100
>> @@ -7,6 +7,7 @@
>>  ===   
>>  """   
>>  import os 
>> +import site   
>>  import sys
>>  import traceback  
>>  import zipfile
>> @@ -430,6 +431,7 @@
>>
>>  def add_path_first(path): 
>>  sys.path = [path]+[p for p in sys.path if (not p==path and not 
>> p==(path+'/'))]
>> +site.addsitedir(path)   
>>   
>>   
>>  
>>  def create_missing_folders():   
>>   
>>  if not global_settings.web2py_runtime_gae:   
>>  
>>
>>
>>
>>

Re: [web2py] Form not processed on first submit

2012-06-29 Thread Johann Spies


On Thursday, 28 June 2012 16:19:34 UTC+2, Anthony wrote:
>
> Hmm, this is a bit hard to follow, and I don't readily see the problem. 
> Somewhere, though, on the initial load, it is creating the form twice but 
> displaying the first version in the view (so the _formkey in the view is 
> outdated). Looks like the reload also creates the form twice, but it is the 
> second one that gets displayed, so the _formkey remains valid. From the 
> code you've shown, I don't quite see how that is happening. Also, where is 
> gekose_skrywers() called -- don't see any reference to it in the early code 
> posted?
>
>
> Apologies.  I see I have left out two controllers which are used as 
components in the check_authors_for_article view:

d
ef list_chosen_authors():
lys = session.skrywers

if request.vars and not request.vars.records:
if request.vars.aksie == 'remove':
session.skrywers.remove(db.akb_authors[request.vars.auid].uuid)

del request.vars.aksie
del request.vars.auid

# sien 
https://groups.google.com/forum/?fromgroups#!topic/web2py/7lYV8ckfvlc
if request.vars.aksie == 'add_similar':

soortgelyk = authid(db.akb_authors[request.vars.auid].surname,
db.akb_authors[request.vars.auid].firstname 
)
uuids  = [x.uuid for x in db(db.akb_authors.auth_id.startswith(
soortgelyk)).select(db.akb_authors.uuid)]
for item in uuids:
lys.add(item)

del request.vars.aksie
del request.vars.auid

if lys:
links = [lambda row:  A(B(T('Remove')),
_href = URL(r = request, c = 'authors',
f = 'list_chosen_authors',
vars = dict(aksie= 'remove',auid
= str(row[db.akb_articles.id]))),
cid = request.cid),
 lambda row:  A(B(T('Add similar')),
_href = URL(r = request, c = 'authors',
f = 'list_chosen_authors',
vars = dict(aksie = 
'add_similar',auid= str(row[db.akb_articles.id]))),
cid = request.cid)]

query = (db.akb_authors.uuid.belongs(lys))
id_lname = db(query).select(db.akb_authors.id, db.akb_authors.
auth_id)
session.ids = [x.id for x in id_lname]
session.lname = set([x.auth_id for x in id_lname])
fields = [db.akb_authors.id, db.akb_authors.surname, db.akb_authors.
firstname,
  db.akb_authors.name, db.akb_authors.birthdate, db.
akb_authors.race,
  db.akb_authors.gender, db.akb_authors.address]
wys = SQLFORM.grid(query, fields = fields, editable = False,deletable
= False,
   selectable = lambda ids: gekose_skrywers(db, ids
),
   links = links, create = False,
   paginate = 100,
   maxtextlength = 90, orderby = db.akb_authors.
surname| db.akb_authors.firstname)

# Sien 
https://groups.google.com/forum/?fromgroups#!topic/web2py/93M1WEdtdOI vir 
onderstaande
#wys.element('.web2py_table input[type=submit]:last')['_onclick'] = 
"window.location = '/init/articles/add_article'"

else:
wys = ''
   
   
return dict(wys=wys)

def publikasievelde():
opskrif = H3(T("Authors and areas of publishing"))
if session.ids:
ids = session.ids
q2 = ((db.akb_authors.id.belongs(ids))&
 (db.akb_authors_article_link.author == db.akb_authors.uuid)&
 (db.akb_authors_article_link.article == db.akb_articles.uuid)&
 (db.akb_journal.uuid == db.akb_articles.journal))


publikasies = SQLTABLE(db(q2).select(db.akb_authors.id, db.
akb_journal.title,
 db.akb_journal.subject,
 groupby = db.akb_authors.id|db.
akb_journal.title|db.akb_journal.subject,
 orderby = db.akb_authors.id|db.
akb_journal.title|db.akb_journal.subject),
   truncate = 130)

return dict(opskrif = opskrif, publikasies = publikasies)
else:
return


The logic runs as follows:

>From the menu 'addarticle' :
 'kryskrywers'  -> check_authors_for_article (which creates session 
variables for 'list_chosen_authors'
The component 'publikasievelde' is just used to provide more information to 
the user to make an informed decision in the selectable grid in 
list_chosen_authors.  The selection is then passed to the module 
'gekose_skrywers'  which redirects to add_article.

Regards
Johann


[web2py] Re: image thumb

2012-06-29 Thread villas
I tried this approach of serving up resized pics on-the-fly before (using 
PHP).  It seemed such a good idea because I could serve up pics of any 
size.  It worked,  but there was a performance hit and the server was not 
happy.  I then introduced a way that the pics would be resized the first 
time requested and thereafter they would be 'cached' for subsequent 
requests.  This also worked but again led to reliability problems which 
periodically required my attention.  I also ended up with huge numbers of 
pics in my cache dir and the system was really slow.

I eventually decided that there were 3 standard sizes that I could use and 
now I create those sizes on uploading my pics.  It is a much better 
solution for me.  It is much faster to serve the pics and with almost zero 
problems and I am very happy with it.  I also use the 'upload_separate' 
parameter to keep my dir sizes small.

Could you also limit yourself to a few standard sizes?  If so,  I suggest 
you take my route.


On Friday, June 29, 2012 1:16:55 AM UTC+1, ctrlSoft wrote:
>
> hi i would like to implement in my app a feature , create thumbs runtime 
> like in picasa or imgur
> original image 
> http://i.imgur.com/E9az6.jpg 
> thumb croped
> http://i.imgur.com/E9az6*b*.jpg  
>
> or in picasa
> original image:
>
> https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/s634/SecureData-logo-design.gif
>  
> thumb croped
>
> https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/
> *s256-c*/SecureData-logo-design.gif
>  
>
> https://lh3.googleusercontent.com/-iNUvq0K9l24/Tyr6IfaT76I/ArI/C_9RUy_o38A/
> *s128-c*/SecureData-logo-design.gif
>  
> 
>
> i want to save just original image and retrieve when i need different size 
> of thumbnail, what is the best way?  any sugestions?
>


[web2py] Re: import modules

2012-06-29 Thread Niphlod
I could use some more explanation.. the site module is imported in the 
interpreter anyway, staring at the docs.

in the first post you say:

Only it does not work with modules installed by python easy-install.
>

in this one

Just installing with PIP or easy_install works
>

I'm surely missing something.

Could you please explain what feature is currently missing in web2py (i.e. 
what you tried to do and didn't work that with the submitted patch 
works...)?
 

Il giorno venerdì 29 giugno 2012 10:33:07 UTC+2, Corne Dickens ha scritto:
>
> It depends on what you do..
>
> Just installing with PIP or easy_install works..
> Installing in web2py/site_packages and before starting web2py add 
> site_packages to the python path also works.
>
> But in web2py its self the site_packages is added to the path, but in that 
> case installed packages are not (or not all of them) recognized.
> Difference is that in case you put a module in site-packages yourself you 
> get a directory 'yourmodule'
> With easy_install / pip you get yourmodule.egg with yourmodule as a subdir.
>
>
>
> Op donderdag 28 juni 2012 16:55:35 UTC+2 schreef Niphlod het volgende:
>>
>> Ahem
>> If I install a module using easy_install web2py recognizes it 
>> correctly (you should use pip, btw)
>>
>> Maybe you are running two different python version and the easy_installed 
>> library is on one interpreter and you run web2py with another 
>> interpreter..
>>
>> Web2py first looks into modules/ of the application folder, than into 
>> site-packages/ of web2py folder and then in normal interpreter paths.
>> so, if you can:
>>
>> >> python
>> >> import this
>>
>> you can also
>>
>> >>python web2py.py
>>
>> and call "import this" in your apps.
>>
>>
>> Il giorno giovedì 28 giugno 2012 16:27:58 UTC+2, Corne Dickens ha scritto:
>>>
>>> Hi,
>>>
>>> Web2py imports modules from the site-packages directory which is a great 
>>> way to build a project withoud any 'external' dependencies.
>>> Only it does not work with modules installed by python easy-install.
>>>
>>> Python it's self uses a site module for this, which can be added to 
>>> web2py in an easy way.
>>> Maybe this is a nice addition for the next version?
>>>
>>> --- web2py/gluon/admin.py   2012-03-04 23:11:41.0 +0100
>>> +++ ../web2py/gluon/admin.py2012-03-08 12:19:52.0 +0100
>>> @@ -7,6 +7,7 @@
>>>  ===   
>>>  """   
>>>  import os 
>>> +import site   
>>>  import sys
>>>  import traceback  
>>>  import zipfile
>>> @@ -430,6 +431,7 @@
>>>
>>>  def add_path_first(path): 
>>>  sys.path = [path]+[p for p in sys.path if (not p==path and not 
>>> p==(path+'/'))]
>>> +site.addsitedir(path)   
>>>   
>>> 
>>>
>>>  def create_missing_folders():   
>>>   
>>>  if not global_settings.web2py_runtime_gae: 
>>>
>>>
>>>
>>>
>>>

Re: [web2py] Routes - simple requirement, but how??

2012-06-29 Thread villas
Hi Anthony

IMO most of the difficulty is not having an easy 'flow diagram' for the 
developer so that he can choose what to do.  I agree that we will of course 
have to keep the parametric router now that we have it.  Here are a few 
points:

1. The pattern router should be named the 'comprehensive' router.

2. The parametric router should be named the 'easy', 'lite' or 'limited' 
router.  It should start off by stating its limitations.  Developers can 
then immediately discard it when it doesn't meet their requirements.

3. It should be made very obvious how the routers in the 'root' (/web2py) 
dir interact with the 'app' routes.

4. For example,  I suggest the root router should go something like this:

default_app = myapp 
## default_app will be applied whenever the app is not obviously 
identifiable

apps_with_own_routers = [app1, app2]
## app1, app2 must have their own routers, which may be 'lite' or 
'comprehensive'

## the following routes do not apply to apps_with_own_routers...
## if default_app is also in apps_with_own_routers (which may only be 
determined after all this file has been parsed) then the routes in this 
file are also ignored.

routes_in ...
routes_out ...

I think that if there were a 'flow' like the above,  it would be much 
easier to understand.

With regards plugin_wiki,  as this is a maintained plugin-in I think we 
should have a special regex for renaming this.  It can be exposed as a 
special parameter:  
alt_name_for_plugin_wiki = myprettyname

Or, better still,  a dict solution for all plugins:
alt_names_for_plugins = dict(plugin_wiki=myprettyname)


Please bear in mind that my suggestions are from the point of view of an 
average user rather than a routing guru,  but I hope this perspective might 
nonetheless help.

Regards,
David

On Thursday, June 28, 2012 6:33:58 AM UTC+1, Anthony wrote:
>
> It is usually a good thing that we have choices,  but not choices of blind 
>> alleys.  IMO  there should be one comprehensive way for web2py to do 
>> routes. If regex patterns are the only way to solve all situations then so 
>> be it - we should just get used to it.  All our efforts can then go in 
>> building up a comprehensive list of recipes and off-the-shelf regex 
>> patterns that we can all just use.
>>
>
> The parameter-based system already exists. Can't we keep it and still 
> build up a list of regex recipes? I'm not sure, but I think some of the 
> things the router handles might get a little hairy with regexes 
> (particularly if combined). I think it works well to have any easy to use 
> router system that handles the most common cases, and then a more advanced 
> (but harder to use) system for the trickier cases.
>  
>
>> The fact that there doesn't seem to be a clear answer to my easy question 
>> already says it all,  but the idea of renaming plugin_wiki as a work-around 
>> puts the issue beyond doubt  :)
>>
>
> Is plugin_wiki the core of your site? If so, perhaps you could use the 
> router and make plugin_wiki the default controller (so it is removed from 
> the URL altogether).
>
> Anthony
>


Re: [web2py] Routes - simple requirement, but how??

2012-06-29 Thread Jonathan Lundell
On Jun 29, 2012, at 5:08 AM, villas wrote:
> 4. For example,  I suggest the root router should go something like this:
> 
> default_app = myapp 
> ## default_app will be applied whenever the app is not obviously identifiable
> 
> apps_with_own_routers = [app1, app2]
> ## app1, app2 must have their own routers, which may be 'lite' or 
> 'comprehensive'

One reason we don't split the functionality this way is that determining the 
application to route to is a (non-trivial) part of the routing function 
(consider for example routing to applications on the basis of domain, port, 
etc). And it's unusual (I think) to have multiple apps in the same installation 
that both need complex but radically different routing.

Re: [web2py] Re: Dynamic virtual fields

2012-06-29 Thread Richard Vézina
I try what Jay suggest, that works, but since eval is risky and not
required, here what I come up with :

inputs_list = []
for a in my_dict:
inputs_list.append(Field(my_dict[a]['field_name']+'_f1',
type='boolean', widget=SQLFORM.widgets.checkboxes.widget,
requires=IS_EMPTY_OR(IS_IN_SET([my_dict[a]['field_name_ui']])))
)
inputs_list.append(Field(my_dict[a]['field_name']+'_f2',
db.ref_tab1,
requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab1.id
','%(MYREPRESENTFIELD1)s')))
)
inputs_list.append(Field(my_dict[a]['field_name']+'_f3',
db.ref_tab2,
requires = IS_EMPTY_OR(IS_IN_DB(db,'ref_tab2.id
','%(MYREPRESENTFIELD2)s')))
)

form = SQLFORM.factory(
Field('other_ref_field_id', db.ref_other,
requires=IS_IN_DB(db,'ref_other.sample_id','%(MYREPRESENT)s')),
*inputs_list, # Unpack my generated fields here...
formstyle='divs'
)

No string, no eval.

Richard

On Sat, Apr 9, 2011 at 10:57 AM, Jay  wrote:

> I use this method for generating totally dynamic forms.
>
> 1. Create an array, say out
> 2. Append "Field(, , )" to this array for all
> fields I need - note this is a string, no function calls
> 3. Wrap the above in an SQLFORM statement.
>  formstring = 'SQLFORM.factory(' +','.join(out)+')'
> 4. Then eval the formstring to get the form
>  form = eval(formstring)
>
> You can use a similar method to create a table in the database
> *** WARNING: I have not tested table creation, but it should work
>  WARNING: You can create the table, but because the definition of
> the table in not in models dir, you will need to keep creating the
> table each time you want to access the table.
> If this table is to exist long term, you can write the generated text
> (like formstring in #3 above) to a file and manually include it in a
> model file.
>
> So to answer your question:
> Do #1-2 as above
> 3. Wrap the above in a define_table statement
>  deftabstring = "define_table(','" + ','.join(out)+')' --
> add "migrate=... as necessary
> 4. Eval the deftabstring to create the table
>  mytab = eval(deftabstring)
>
> Assuming you use 'db' to get to the database, you can now user
> db. to get to your table. *Keep the second warning in
> mind.*
>
> Aside: Many people out there do not like the use of eval, and will
> criticize it right away. I use it when it is necessary.
> NEVER USE EVAL WHEN THERE IS CHANCE OF USER INPUT IN UNPROCESSED FORM
> BEING PART OF WHAT YOU EVAL, because you open a way to get hacked.
> NEVER FORGET THIS!
>
> This is where programming gets interesting.
>
> Jay
>
> On Apr 9, 7:34 am, Serbitar  wrote:
> > Sorry, misstyped and sent the message early. So once again:
> >
> > I can create database fields from a list like this:
> >
> > list = ["a","b","c","d"]
> > fields = []
> > for entry in list:
> > fields += [Field(entry, type="string")]
> > db.define_table('test', *fields)
> >
> > Now I want to have a virtual field for each field in the list.
> > Any way to do this? As virtual field names are not strings but
> > function names I got no idea how to do this.
>


[web2py] Re: send a tweet from web2py

2012-06-29 Thread Elcimar
Does this still works nowadays?

Em quinta-feira, 7 de maio de 2009 17h01min07s UTC-3, weheh escreveu:
>
> awesome



Re: [web2py] Routes - simple requirement, but how??

2012-06-29 Thread Anthony

>
> 1. The pattern router should be named the 'comprehensive' router.
>
> 2. The parametric router should be named the 'easy', 'lite' or 'limited' 
> router.  It should start off by stating its limitations.  Developers can 
> then immediately discard it when it doesn't meet their requirements.
>

Have you read through this section: 
http://web2py.com/books/default/chapter/29/4#URL-rewrite. I believe it 
communicates exactly what you suggest above. Some excerpts:

web2py includes two distinct URL rewrite systems: an easy-to-use *
parameter-based* system for most use cases, and a flexible *pattern-based* 
system 
for more complex cases...

The parameter-based (parametric) router provides easy access to several 
"canned" URL-rewrite methods. Its capabilities include: [goes on to list 
specific capabilities]...

Although the *parameter-based* system just described should be sufficient 
for most use cases, the alternative *pattern-based* system provides some 
additional flexibility for more complex cases...


Regarding the naming, I'm sure opinions will vary (I prefer the more 
functionally descriptive "parameter-based" and "pattern-based"). Anyway, 
the naming isn't part of the API, just a shorthand reference for 
documentation and discussion.
 

> Or, better still,  a dict solution for all plugins:
> alt_names_for_plugins = dict(plugin_wiki=myprettyname)
>

Yes, that would be great.

Anthony


[web2py] Re: send a tweet from web2py

2012-06-29 Thread Anthony
Should, unless Twitter changed there API (in which case, probably something 
similar would work). Give it a try and let us know.

On Friday, June 29, 2012 9:35:42 AM UTC-4, Elcimar wrote:
>
> Does this still works nowadays?
>
> Em quinta-feira, 7 de maio de 2009 17h01min07s UTC-3, weheh escreveu:
>>
>> awesome
>
>

[web2py] Virtual Machines on Google

2012-06-29 Thread Michele Comitini
It was about time.
I like GAE but having a full OS gives more degrees of freedom.

https://developers.google.com/compute/

mic


[web2py] Re: Using admin interface on GAE, getting errors on update or insert

2012-06-29 Thread howesc
looks like whatever you are doing has triggered a query that needs the 
index.  have you run this in development mode on your desktop first?  that 
should trigger the creation of the index.yaml file automagically.

the missing fields in the GAE datastore viewer is because bigtable is 
schemaless, so it does not know what fields you might want to have.  it 
makes a guess based on what fields existing entries of that kind have.

On Friday, June 22, 2012 2:29:33 PM UTC-7, mike haberman wrote:
>
> New to web2py and GAE.  But with a very simple example, I 
> am unable to use web2py admin interface to modify the database
>
> Using the admin interface for an application,
> I can navigate to 'Administrative Interface' --> Applications --> (blog) 
>  Edit --> Models --> database administration
>
> I can update/insert on any of the auth_ tables
> but I get the following error on any table that I create within models for 
> web2py
>
>  no matching 
> index found. 
> The suggested index for this query is: - kind: auth_user properties: - 
> name: first_name - name: last_name
>
> Is there something I need to do to the model definition to avoid this 
> error ?
>
> (Also when trying to create a new entity via GAE's Datastore viewer, some 
> fields are missing 
> even though it displays all the fields for each entity from a query.  Is 
> there something by default that
> makes some fields not show up?)
>
>
> thanks
>
> mike
>
>

[web2py] Re: VPS Hosting in Canada

2012-06-29 Thread Don_X
hey Rod ...

check out myhosting.com for a good custom VPS deal 
As soon as I finished with my app ... this is where I'll be heading to 

there VPS packages are cheaper than iweb ...

good luck ...

Don

On Tuesday, 26 June 2012 10:22:55 UTC-4, Rod Watkins wrote:
>
> Hello everyone,
>
> I will soon be needing a hosting provider, preferably a vps hosting 
> service, with servers based in Canada (for privacy and legal reasons). I 
> know that there are posts on hosting services, but I wanted to get feedback 
> from anyone who has experience with ones based in or with servers 
> physically within Canada. I like the idea of a vps server rather than 
> shared hosting since it avoids several complications. So if I could get any 
> recommendations or warning about who to avoid, I would really appreciate 
> your input.
>
> Thanks
>
> Rod Watkins
>
>

Re: [web2py] Re: Multi_tenant

2012-06-29 Thread Michele Comitini
Ovidio,

I wonder if you could use auth.user.id or auth.membership.id as key
instead of host/ip?

If the above is not viable, Massimo suggestion to have separate
databases is very good IMHO and you can build a Data Warehouse
http://en.wikipedia.org/wiki/Data_warehouse by using postgresql
clustering capabilities or one of many postgresql synchronization
tools.

mic


2012/6/29 Ovidio Marinho :
> Well now after my DAL I have Instructions
> db = DAL ('postgres :/ / postgres: passwd @ localhost: 5432/mybd')
> db._common_fields=Field('request_tenant',default=request.env.http_host,writable=False,readable=False)]
>
> What happened? in all my tables I have request_tenant the field, and
> when I do a drive automatically writes the localhost: 8000. But now
> how is that several users with different hosts with dhcp changing its
> access each time with a different ip that can work?
>
> this post from Massimo does exactly what I want with the school he has
> provided for various and simultaneous access, I could spend the
> Massimo setting this app?
>
> http://www.mail-archive.com/web2py@googlegroups.com/msg64351.html
>
>        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
>
>
>
> 2012/6/28 Massimo Di Pierro :
>> Do me the issue is, should all data always be filtered by hospital.
>> If there should only be filtered in some cases and not in other, use
>> explicit queries
>> If some tables are always filtered and some are not, you may want to use the
>> tenant feature.
>>
>>
>> On Thursday, 28 June 2012 05:45:13 UTC-5, Ovidio Marinho wrote:
>>>
>>> I can not split into separate database, as the management reports need
>>> to filter all information. What I need is that the data are shown to
>>> hosptal (1) is only seen by him. No problem if all hospitals being in
>>> the same database, so is the question of security in view. When the
>>> login Hospital (1) is made only data related to hospital (1) should
>>> appear on the screen.
>>>
>>>
>>>
>>>
>>>        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
>>>
>>>
>>>
>>> 2012/6/27 Massimo Di Pierro :
>>> > I would suggest you use a different database (a different connection
>>> > string)
>>> > for each hospital depending on the hostname.
>>> >
>>> > .domain.com
>>> > import re; regex = re.compile('.*\://(.*?)/.*
>>> > db = DAL('postgresq:///%s' %
>>> > regex.match(request.env.http_host).group(1))
>>> >
>>> > In this way you keep your data separate (which is better for security)
>>> > and
>>> > will allow you scale horizontally by setting up multiple db server
>>> > instances.
>>> >
>>> >
>>> >
>>> > On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote:
>>> >>
>>> >> I am making an application to control government medical appointments
>>> >> in more than fifty hospitals all use a single postgres database, but
>>> >> each hospital must have administrator access, Operator and User, and
>>> >> each access must be made with the view of their unique data .
>>> >>
>>> >> is this.
>>> >>
>>> >>
>>> >


[web2py] standalone we-app example

2012-06-29 Thread orsomannaro

How can I dowload a web2py standalone web-app example?

Tnk.


Re: [web2py] Routes - simple requirement, but how??

2012-06-29 Thread villas
@Jonathan.
Parametric Router.  I just read the book again and I had overlooked that 
with the parametric router you cannot have app specific routes in the app 
folder.  That is a shame because I had always thought a main advantage of 
having an app specific routes.py is so that it could be distributed with 
the app.  This in itself may be a reason to avoid it.  An app that depends 
on this functionality cannot be distributed in the normal way?

I cannot see why the root routes.py cannot determine whether it has 
recognised an app.  Afterall,  we are telling it the app names.

I am suggesting the flow as follows:
1. Look for root routes.py.
2. See whether there are any apps specified which have their own routing.  
The test for this is simply to look at the first arg of the URL after the 
domain:port.  The routes can already do that,  can't they?  
3. If app specific routes apply,  then go and get the app/routes.py and 
follow that.
4. If not,  then follow the default routes.

In all cases,  the user can opt for parametric routes or pattern routes.  
Maybe a flag at the start of each file should make it clear which.

I am not asking for anything which isn't already available in one form or 
another.  You are saying it is non-trivial.  Well I definitely agree with 
that!  However,  if it already available,  then surely it is possible.

@Anthony.  As you say, the naming is not really an issue as long as 
everything is clear and you suggest the documentation is pretty adequate -- 
but evidently it is not.  In my original post above,  I described a simple 
case which appears to be possible with the parametric router,  but you 
concede that it is not. This has got me wondering how we might make all 
this more obvious,  so that in future people like me can figure it out 
without wasting other peoples' time.  

In referring back to my original post,  I am hoping that this test case 
will be a catalyst to getting a clearer routing solution.
Thanks,  David



On Friday, June 29, 2012 2:06:43 PM UTC+1, Jonathan Lundell wrote:
>
> On Jun 29, 2012, at 5:08 AM, villas wrote:
>
> 4. For example,  I suggest the root router should go something like this:
>
> default_app = myapp 
> ## default_app will be applied whenever the app is not obviously 
> identifiable
>
> apps_with_own_routers = [app1, app2]
> ## app1, app2 must have their own routers, which may be 'lite' or 
> 'comprehensive'
>
>
> One reason we don't split the functionality this way is that determining 
> the application to route to is a (non-trivial) part of the routing function 
> (consider for example routing to applications on the basis of domain, port, 
> etc). And it's unusual (I think) to have multiple apps in the same 
> installation that both need complex but radically different routing.
>


Re: [web2py] Routes - simple requirement, but how??

2012-06-29 Thread Jonathan Lundell
On Jun 29, 2012, at 8:47 AM, villas wrote:
> @Jonathan.
> Parametric Router.  I just read the book again and I had overlooked that with 
> the parametric router you cannot have app specific routes in the app folder.  
> That is a shame because I had always thought a main advantage of having an 
> app specific routes.py is so that it could be distributed with the app.  This 
> in itself may be a reason to avoid it.  An app that depends on this 
> functionality cannot be distributed in the normal way?
> 
> I cannot see why the root routes.py cannot determine whether it has 
> recognised an app.  Afterall,  we are telling it the app names.
> 
> I am suggesting the flow as follows:
> 1. Look for root routes.py.
> 2. See whether there are any apps specified which have their own routing.  
> The test for this is simply to look at the first arg of the URL after the 
> domain:port.  The routes can already do that,  can't they?  
> 3. If app specific routes apply,  then go and get the app/routes.py and 
> follow that.
> 4. If not,  then follow the default routes.

Example: both routers are capable of routing to an application based on some 
combination of scheme, domain & port, in which case the app name is typically 
not present in the incoming URL.

> 
> In all cases,  the user can opt for parametric routes or pattern routes.  
> Maybe a flag at the start of each file should make it clear which.
> 
> I am not asking for anything which isn't already available in one form or 
> another.  You are saying it is non-trivial.  Well I definitely agree with 
> that!  However,  if it already available,  then surely it is possible.
> 
> @Anthony.  As you say, the naming is not really an issue as long as 
> everything is clear and you suggest the documentation is pretty adequate -- 
> but evidently it is not.  In my original post above,  I described a simple 
> case which appears to be possible with the parametric router,  but you 
> concede that it is not. This has got me wondering how we might make all this 
> more obvious,  so that in future people like me can figure it out without 
> wasting other peoples' time.  
> 
> In referring back to my original post,  I am hoping that this test case will 
> be a catalyst to getting a clearer routing solution.




Re: [web2py] Re: How to populate list:reference field?

2012-06-29 Thread Alec Taylor
Thanks, got it working: groups_list =
SQLTABLE(db().select(db.group_of_events.ALL, db.event.ALL,
left=db.event.on(db.event.group_id==db.group_of_events.id)))

:D

On Thu, Jun 28, 2012 at 5:21 AM, Anthony  wrote:
> Have you read this
> section: http://web2py.com/books/default/chapter/29/6#One-to-many-relation?
> (Think person=group and dog=event.)
>
>
> On Wednesday, June 27, 2012 12:42:40 PM UTC-4, Alec Taylor wrote:
>>
>> I was planning to have a many groups to 1 event relation, but now that
>> I think of it, there are better ways of accomplishing that.
>>
>> How do I do the n+1 unrolling simply?
>>
>> I.e.: how do I create a list using SQLFORM (or similar) which finds
>> and displays in a list all [events in [db.event for each group in
>> db.group_of_events]]?`
>>
>> On Thu, Jun 28, 2012 at 2:34 AM, Anthony wrote:
>> > Actually, why do you need the "events" field in group_of_events? If you
>> > want
>> > a one-to-many relation with db.event, you've already got it with the
>> > db.event.group_id field. What workflow are you trying to create?
>> >
>> > Anthony
>> >
>> >
>> > On Wednesday, June 27, 2012 12:09:50 PM UTC-4, Alec Taylor wrote:
>> >>
>> >> Thanks, that fixed some other problems, but my initial problem of not
>> >> getting the list of events associated with each group is still
>> >> present.
>> >>
>> >> >> db.define_table(
>> >> >>     'group_of_events',
>> >> >>     Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db,
>> >> >> 'group_of_events.group_name')]),
>> >> >>     Field('events', 'list:reference db.event',
>> >> >> requires=[IS_IN_DB(db,
>> >> >> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)])
>> >> >
>> >> >
>> >> > When you put the IS_IN_DB validator in a list, you do not get the
>> >> > standard
>> >> > dropdown (for single items) or multiple select widget (for multiple
>> >> > items).
>> >> > Change the above to:
>> >> >
>> >> >     requires=IS_IN_DB(db, 'event.id', '%(event_name)s
>> >> > [%(group_id)s]',
>> >> > multiple=True)
>> >> > Anthony
>> >> >
>> >> > --
>> >> >
>> >> >
>> >> >
>> >
>> > --
>> >
>> >
>> >


[web2py] Re: Virtual Machines on Google

2012-06-29 Thread Massimo Di Pierro
+1

On Friday, 29 June 2012 08:58:09 UTC-5, Michele Comitini wrote:
>
> It was about time. 
> I like GAE but having a full OS gives more degrees of freedom. 
>
> https://developers.google.com/compute/ 
>
> mic 
>


[web2py] Re: Specify update column

2012-06-29 Thread naveed
Awesome! Thanks, Anthony

Re: [web2py] Routes - simple requirement, but how??

2012-06-29 Thread Anthony

>
> Parametric Router.  I just read the book again and I had overlooked that 
> with the parametric router you cannot have app specific routes in the app 
> folder.


Actually, according to the example file, you can have app-specific routes 
in the app folder if desired: 
http://code.google.com/p/web2py/source/browse/router.example.py#6. This is 
not mentioned in the book.
 

> I am suggesting the flow as follows:
> 1. Look for root routes.py.
> 2. See whether there are any apps specified which have their own routing.  
> The test for this is simply to look at the first arg of the URL after the 
> domain:port.  The routes can already do that,  can't they?  
> 3. If app specific routes apply,  then go and get the app/routes.py and 
> follow that.
> 4. If not,  then follow the default routes.
>

Isn't this basically how it already works (for both systems)? I think the 
only catch is that if you do have app-specific routes in the application 
folder, you also have to have a routes.py in the root folder in order to 
indicate that (i.e., if there's no root routes.py, it won't attempt to do 
any rewriting).
 

> @Anthony.  As you say, the naming is not really an issue as long as 
> everything is clear and you suggest the documentation is pretty adequate -- 
> but evidently it is not.


Here's what I said earlier:

*Yes, I think the rewrite documentation could be improved, particularly 
with more examples for cases like this.*


I agree the documentation can be improved. I wasn't claiming the 
documentation is generally adequate -- only that it does appear to 
adequately communicate the particular point you were making, namely, that 
the parameter-based system is simpler but has limitations and the 
pattern-based system more complex but more flexible.

Anthony


[web2py] Re: Multi_tenant

2012-06-29 Thread Maxwell Morais
Ovidio,
Este link, pode te ajudar com a sua dúvida!

http://balaiotecnologico.blogspot.com.br/2011/03/sua-solucao-saas-e-multi-tenant.html

Em quarta-feira, 27 de junho de 2012 16h48min34s UTC-3, Ovidio Marinho 
escreveu:
>
>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 
>
>
>
>
> -- Forwarded message -- 
> From: Ovidio Marinho  
> Date: 2012/6/27 
> Subject: Multi_tenant 
> To: web2py@googlegroups.com 
>
>
> Procurei isto nas listas todo mundo fala e ninguem esclarece como esta 
> coisa funciona com claridade. 
>
> I tried that lists everyone talks and no one explains how this thing 
> works with clarity. 
>
>
>
>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] Re: VPS Hosting in Canada

2012-06-29 Thread Alexander Kiss
Hello to everybody, I am a new user in this group (still learning 
python, and looking for a framework) if someone wants a vps then I 
recommend them http://vpscheap.net/linux.aspx it's quite a while since I 
became their customer and I must say it's worth every little cent that I 
am paying.



As soon as I am done reading the documentation I will get back here to 
you guys (I am looking to build a document management system with OCR 
capabilities)



Best regards,
Alex


On 29/06/2012 16:43, Don_X wrote:

hey Rod ...

check out myhosting.com for a good custom VPS deal 
As soon as I finished with my app ... this is where I'll be heading to 



there VPS packages are cheaper than iweb ...

good luck ...

Don

On Tuesday, 26 June 2012 10:22:55 UTC-4, Rod Watkins wrote:

Hello everyone,

I will soon be needing a hosting provider, preferably a vps
hosting service, with servers based in Canada (for privacy and
legal reasons). I know that there are posts on hosting services,
but I wanted to get feedback from anyone who has experience with
ones based in or with servers physically within Canada. I like the
idea of a vps server rather than shared hosting since it avoids
several complications. So if I could get any recommendations or
warning about who to avoid, I would really appreciate your input.

Thanks

Rod Watkins






Re: [web2py] Re: VPS Hosting in Canada

2012-06-29 Thread Richard Vézina
Nice project Alex!

I will be happy to heard about that.

See you here soon.

Richard

On Fri, Jun 29, 2012 at 11:11 AM, Alexander Kiss  wrote:

>  Hello to everybody, I am a new user in this group (still learning
> python, and looking for a framework) if someone wants a vps then I
> recommend them http://vpscheap.net/linux.aspx  it's quite a while since I
> became their customer and I must say it's worth every little cent that I am
> paying.
>
>
> As soon as I am done reading the documentation I will get back here to you
> guys (I am looking to build a document management system with OCR
> capabilities)
>
>
> Best regards,
> Alex
>
>
>
> On 29/06/2012 16:43, Don_X wrote:
>
> hey Rod ...
>
> check out myhosting.com for a good custom VPS deal 
> As soon as I finished with my app ... this is where I'll be heading to 
>
> there VPS packages are cheaper than iweb ...
>
> good luck ...
>
> Don
>
> On Tuesday, 26 June 2012 10:22:55 UTC-4, Rod Watkins wrote:
>>
>> Hello everyone,
>>
>>  I will soon be needing a hosting provider, preferably a vps hosting
>> service, with servers based in Canada (for privacy and legal reasons). I
>> know that there are posts on hosting services, but I wanted to get feedback
>> from anyone who has experience with ones based in or with servers
>> physically within Canada. I like the idea of a vps server rather than
>> shared hosting since it avoids several complications. So if I could get any
>> recommendations or warning about who to avoid, I would really appreciate
>> your input.
>>
>>  Thanks
>>
>>  Rod Watkins
>>
>>
>
>


Re: [web2py] Re: Multi_tenant

2012-06-29 Thread Cliff Kachinske
You can use auth.user.request_tenant as the default, but you must be 
careful because auth is not present before the user logs in.  Therefore you 
will get key errors if a user not logged in attempts to access a function.

So, insert something like the following in your model before auth creates 
the tables:

request_tenant_default = ''
if 'auth' in session:
  request_tenant_default = session.auth.user.tenant_link


Then this:

db.common_fields = Field('tenant_link', default=request_tenant_default, ...)


Also every user-accessible function must have at least 
@auth.requires_login()




On Friday, June 29, 2012 10:53:42 AM UTC-4, Michele Comitini wrote:
>
> Ovidio, 
>
> I wonder if you could use auth.user.id or auth.membership.id as key 
> instead of host/ip? 
>
> If the above is not viable, Massimo suggestion to have separate 
> databases is very good IMHO and you can build a Data Warehouse 
> http://en.wikipedia.org/wiki/Data_warehouse by using postgresql 
> clustering capabilities or one of many postgresql synchronization 
> tools. 
>
> mic 
>
>
> 2012/6/29 Ovidio Marinho : 
> > Well now after my DAL I have Instructions 
> > db = DAL ('postgres :/ / postgres: passwd @ localhost: 5432/mybd') 
> > 
> db._common_fields=Field('request_tenant',default=request.env.http_host,writable=False,readable=False)]
>  
>
> > 
> > What happened? in all my tables I have request_tenant the field, and 
> > when I do a drive automatically writes the localhost: 8000. But now 
> > how is that several users with different hosts with dhcp changing its 
> > access each time with a different ip that can work? 
> > 
> > this post from Massimo does exactly what I want with the school he has 
> > provided for various and simultaneous access, I could spend the 
> > Massimo setting this app? 
> > 
> > http://www.mail-archive.com/web2py@googlegroups.com/msg64351.html 
> > 
> >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 
> > 
> > 
> > 
> > 2012/6/28 Massimo Di Pierro : 
> >> Do me the issue is, should all data always be filtered by hospital. 
> >> If there should only be filtered in some cases and not in other, use 
> >> explicit queries 
> >> If some tables are always filtered and some are not, you may want to 
> use the 
> >> tenant feature. 
> >> 
> >> 
> >> On Thursday, 28 June 2012 05:45:13 UTC-5, Ovidio Marinho wrote: 
> >>> 
> >>> I can not split into separate database, as the management reports need 
> >>> to filter all information. What I need is that the data are shown to 
> >>> hosptal (1) is only seen by him. No problem if all hospitals being in 
> >>> the same database, so is the question of security in view. When the 
> >>> login Hospital (1) is made only data related to hospital (1) should 
> >>> appear on the screen. 
> >>> 
> >>> 
> >>> 
> >>> 
> >>>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 
> >>> 
> >>> 
> >>> 
> >>> 2012/6/27 Massimo Di Pierro : 
> >>> > I would suggest you use a different database (a different connection 
> >>> > string) 
> >>> > for each hospital depending on the hostname. 
> >>> > 
> >>> > .domain.com 
> >>> > import re; regex = re.compile('.*\://(.*?)/.* 
> >>> > db = DAL('postgresq:///%s' % 
> >>> > regex.match(request.env.http_host).group(1)) 
> >>> > 
> >>> > In this way you keep your data separate (which is better for 
> security) 
> >>> > and 
> >>> > will allow you scale horizontally by setting up multiple db server 
> >>> > instances. 
> >>> > 
> >>> > 
> >>> > 
> >>> > On Wednesday, 27 June 2012 18:07:44 UTC-5, Ovidio Marinho wrote: 
> >>> >> 
> >>> >> I am making an application to control government medical 
> appointments 
> >>> >> in more than fifty hospitals all use a single postgres database, 
> but 
> >>> >> each hospital must have administrator access, Operator and User, 
> and 
> >>> >> each access must be made with the view of their unique data . 
> >>> >> 
> >>> >> is this. 
> >>> >> 
> >>> >> 
> >>> > 
>


[web2py] Re: Form submission and "view page source"

2012-06-29 Thread Cliff Kachinske
Couldn't a Man In The Middle attacker hijack the form key since it goes by 
post?

Then keep hitting the server with a bogus request that includes the 
hijacked key.

On Friday, June 29, 2012 12:51:59 AM UTC-4, Anthony wrote:
>
> The easiest way is to implement this is to replace self.formkey and 
>> self.session.formkey in gluon/html.py so that it store not one key but the 
>> last 10 keys.
>>
>
> The number should be configurable.
>  
>
>> I am still unsure about this. We can make it work but allowing the past 
>> 10 open forms to still be submitted can be considered a vulnerability.
>>
>
> How would that be exploited?
>
> Anthony 
>


[web2py] Re: Form submission and "view page source"

2012-06-29 Thread Cliff Kachinske
Are you sending them back via redirect() or some other way?

On Friday, June 29, 2012 3:45:26 AM UTC-4, Neil wrote:
>
>
>
>> It shouldn't happen "randomly". It should only happen when you open the 
>> same page (or any page with a form that has the same formname) in the same 
>> browser, and then go back to the original page and try to submit the 
>> original form. We've talked about allowing multiple versions of the 
>> _formkey for the same form to avoid this problem, but that hasn't been 
>> implemented yet.
>>
>
> Thanks - this has been very useful. It is definitely happening for me 
> without opening a new page/tab in the browser, but is very inconsistent. A 
> bit more information: my site guides the user from one page to the next, 
> but occasionally loops back on itself to an earlier page, depending on user 
> input. This problem seems to occur (inconsistently) when revisiting pages 
> they've already been to. I suppose there is some sort of conflict with the 
> _formname. Assigning a unique formname should do the trick.
>
> Thanks again,
> Neil
>


Re: [web2py] Re: database locking web2py vs. "external" access...

2012-06-29 Thread Doug Philips
On Thu, Jun 28, 2012 at 8:04 AM, Anthony  wrote:
>> > Anyway, you might be better off looking into using the scheduler, or a
>> > third-party task queue like Celery (a web2py Celery plugin was started
>> > at
>> > some point, though not sure it is complete).
>>
>> I don't understand, how will that let me do a read-modify-update
>> transaction? It seems as if for_update is precisely what I need to do
>> that.
>
> I thought your original goal was to set up a task queue -- those suggestions
> are specialized for that purpose.

Yes, it is. The email-queue example in The Book has a caveat that only
one server can be used. That's because with more than one server
process, the same work item might be processed several times. If I had
a read-modify-update transaction, then a server could mark a
particular work item as taken/in-progress and it wouldn't matter how
many servers I had. It would work with just one, or if I needed to
spin up a few more, I could that without introducing errors,
race-conditions, etc. Right?

-=Doug


[web2py] Server side rendering requiring js library. Svg to png. D3.js

2012-06-29 Thread Andrew
Hello, 
I have been using the wonderful d3 library with web2 py.  See http://d3js.org/ 
for more information.  But it is aimed at the browser.  It is great to 
visualise json output from web2py.

One thing it does is generate svg content.  I would like to be able to generate 
a png image from the svg definition, but on the server.  I know it's possible 
with phantom.js and node.js (from another group: 
https://groups.google.com/forum/m/?fromgroups#!topic/d3-js/XHbidy5pY8A),  but 
I'm not sure if they fit into a web2py context,  or if that is the right 
approach with web2py.  Does something like a "Headless web kit browser" fit 
into web2py approach?
.
I'm wondering is it possible, using something like response.render to generate 
the svg in a controller and generate a png image (which I could save or include 
in PDF output).  Would I include these other libraries, but where, in the view? 
 

Anyway, I think d3 is fantastic and it would be great to be able to exploit it 
(more!) in web2py.  Happy to put up some simple examples that show how to do it 
(the browser part at least) 

Thanks


[web2py] Re: Use of custom CSS, HTML and JS for the view

2012-06-29 Thread mrtn

Thanks a lot for the clarifications!


[web2py] debugging procedure

2012-06-29 Thread Janath
Hi,

So far I have connected the algorithms that I developed in python IDLE to 
web2py. 

I would like to debug from web2py as I need to find out some errors that I 
do not see in IDLE.

I have tried setting breakpoints, but couldn't figure out the proper way of 
doing it. I need to check the variable values at a breakpoint.

Appreciate if someone points me to an article or a screen captured video or 
etc.

Janath 


[web2py] A page served by two different backends

2012-06-29 Thread cyan

I want to implement a page that is served by two backends, one is tornado 
and the other is web2py, and this concerns two questions below:

1. The tornado serves the dynamic part of the content on the page (together 
with some help from frontend Javascript), while the web2py handles the rest 
of all static content. Is this something that can be easily configured and 
handled by web2py? If so, how should I setup it up the page? 

2. By using a single user action (e.g. clicking on a button), I want to 
retrieve some static content (e.g. some parameter values stored in the db 
behind web2py) from web2py, and pass on these values to the tornado server. 
What is the appropriate workflow/logic for implementing this within web2py? 
Is it simple as send a request to web2py, get the values back and then 
programmatically generate another POST request to tornado? Thanks.


[web2py] Re: A page served by two different backends

2012-06-29 Thread Massimo Di Pierro
I am not sure what you mean by "static content". web2py is good at 
generating dynamic content but if you have static pages and files you are 
better-off by-passing web2y and tornado has a StaticHandler object.

On Friday, 29 June 2012 16:24:23 UTC-5, cyan wrote:
>
>
> I want to implement a page that is served by two backends, one is tornado 
> and the other is web2py, and this concerns two questions below:
>
> 1. The tornado serves the dynamic part of the content on the page 
> (together with some help from frontend Javascript), while the web2py 
> handles the rest of all static content. Is this something that can be 
> easily configured and handled by web2py? If so, how should I setup it up 
> the page? 
>
> 2. By using a single user action (e.g. clicking on a button), I want to 
> retrieve some static content (e.g. some parameter values stored in the db 
> behind web2py) from web2py, and pass on these values to the tornado server. 
> What is the appropriate workflow/logic for implementing this within web2py? 
> Is it simple as send a request to web2py, get the values back and then 
> programmatically generate another POST request to tornado? Thanks.
>


[web2py] Re: Web2Py compute fields not working on update

2012-06-29 Thread web2py_Superfan
I have a much older build, and I have this issue as well.  The compute 
field gives me an error when I do an update, 'key error' image

On Wednesday, June 20, 2012 9:08:31 PM UTC-7, Brandon Reynolds wrote:
>
> If i am not the only one not having i think it's possible it may be a 
> web2py bug. I bet it is only a bug in update fields as i have seem some 
> other complaints online. I have filed a bug ticket. Hopefully it is fixed 
> soon. I am only a beginner programmer so i still am learning debugging and 
> how python and web2py function. I am more than happy to try and help get 
> this fixed.
>
> I appreciate the helpfulness of everyone in this group and the web2py 
> devs. You guys rock and i am glad i chose web2py over it's alternatives. I 
> never got this much help when i was writing php!
>
> Thanks Again,
> Brandon
>
> On Wednesday, June 20, 2012 4:15:46 PM UTC-6, pbreit wrote:
>>
>> Oh, my bad. You're right, looks like not updating. Will dig in more. 
>> Sorry about that.
>
>

[web2py] Re: Web2Py compute fields not working on update

2012-06-29 Thread web2py_Superfan
as a workaround in my update statement, I updated the computed field to be 
the computed field via 

mint_order = 
db(db.mint_orders2.id==coin.deannas_dough.mint_orders_id).select(db.mint_orders2.ALL)[0]
db(db.mint_orders2.id==mint_order.id).update(num_won=num_won+1,image_thumb=mint_order.image_thumb)

On Friday, June 29, 2012 5:01:24 PM UTC-7, web2py_Superfan wrote:
>
> I have a much older build, and I have this issue as well.  The compute 
> field gives me an error when I do an update, 'key error' image
>
> On Wednesday, June 20, 2012 9:08:31 PM UTC-7, Brandon Reynolds wrote:
>>
>> If i am not the only one not having i think it's possible it may be a 
>> web2py bug. I bet it is only a bug in update fields as i have seem some 
>> other complaints online. I have filed a bug ticket. Hopefully it is fixed 
>> soon. I am only a beginner programmer so i still am learning debugging and 
>> how python and web2py function. I am more than happy to try and help get 
>> this fixed.
>>
>> I appreciate the helpfulness of everyone in this group and the web2py 
>> devs. You guys rock and i am glad i chose web2py over it's alternatives. I 
>> never got this much help when i was writing php!
>>
>> Thanks Again,
>> Brandon
>>
>> On Wednesday, June 20, 2012 4:15:46 PM UTC-6, pbreit wrote:
>>>
>>> Oh, my bad. You're right, looks like not updating. Will dig in more. 
>>> Sorry about that.
>>
>>

[web2py] Re: Use of custom CSS, HTML and JS for the view

2012-06-29 Thread mrtn

One follow-up question:

More generally, if a controller action returns a form object to the view, 
how does the view renders the fields/variables in that form? Does the 
rendering depend on web2py.css and/or web2py.js? If so, does it mean that I 
have to manually set the variables (such as form.vars.var1, etc) to the 
individual fields if I use custom HTML page with custom CSS layout?


[web2py] Re: A page served by two different backends

2012-06-29 Thread cyan

By 'static content', I mean things like the layout, links, labels, buttons, 
input fields, tables, etc. On the other hand, values of the labels and 
those of the table are dynamic, such that they refreshes themselves as new 
values arrive via websockets.

Every other pages of the app will be served using web2py, which is why I 
want to keep things consistent and have web2py serve all the static content 
of this page too.


[web2py] advice and help on csv input

2012-06-29 Thread song
Nowdays I study the web2py.
I met the problems for me only.
By the appadmin.py, the database was constructed.
Then at the 'state' , there are problemes in the CSV import.

db files

#
db.define_table('country',
Field('name', unique=True),
Field('iso'),
Field('numcode')
)

db.define_table('state',
Field('country_iso',db.country),
Field('subcountry_code','string'),
Field('name','string'),
Field('subcountry_level','string')
)

db.country.name.requires = IS_NOT_IN_DB(db,db.country.name)
db.country.name.requires = IS_NOT_EMPTY()

db.state.name.requires = IS_NOT_EMPTY()
db.state.country_iso.requires = IS_IN_DB(db, db.country.iso,'%(iso)s')

and csv files

name,iso,numcode
Afghanistan,AF,4
Albania,AL,8
Algeria,DZ,12
American Samoa,AS,16
Andorra,AD,20
Angola,AO,24
Anguilla,AI,660
Antarctica,AQ,10
Antigua and Barbuda,AG,28
Argentina,AR,32
Armenia,AM,51
Aruba,AW,533
Australia,AU,36
Austria,AT,40
Azerbaijan,AZ,31
Bahamas,BS,44
Bahrain,BH,48
Bangladesh,BD,50
Barbados,BB,52
Belarus,BY,112
Belgium,BE,56
Belize,BZ,84
Benin,BJ,204
Bermuda,BM,60
Bhutan,BT,64


country_iso,subcountry_code,name,subcountry_level
AD,AN,Andorra la Vella,NULL
AD,CA,Canillo,NULL
AD,EE,Escaldes-Engordany,NULL
AD,EN,Encamp,NULL
AD,JL,Sant Julià de Lòria,NULL
AD,MA,La Massana,NULL
AD,OR,Ordino,NULL
AE,AJ,Ajman,NULL
AE,AZ,Abu Z¸aby [Abu Dhabi],NULL
AE,DU,Dubayy [Dubai],NULL
AE,FU,Al Fujayrah,NULL
AE,RK,Ras al Khaymah,NULL
AE,SH,Ash Shariqah [Sharjah],NULL
AE,UQ,Umm al Qaywayn,NULL
AF,BAL,Balkh,NULL
AF,BAM,Bamian,NULL
AF,BDG,Badghis,NULL
AF,BDS,Badakhshan,NULL
AF,BGL,Baghlan,NULL
AF,FRA,Farah,NULL

Which parts are modified for corrected input?



[web2py] Re: Use of custom CSS, HTML and JS for the view

2012-06-29 Thread Massimo Di Pierro
The rendering does not require any particular css or js.

It did use css for the style of the input fields and textareas. Now it 
relies on boostrap.css for that. Whether this change was a good idea I am 
not completely sure of. web2py.js is not required for forms. It is required 
for slashing messages, client side form validation, and components (forms 
submitted via ajax).

On Friday, 29 June 2012 19:47:50 UTC-5, mrtn wrote:
>
>
> One follow-up question:
>
> More generally, if a controller action returns a form object to the view, 
> how does the view renders the fields/variables in that form? Does the 
> rendering depend on web2py.css and/or web2py.js? If so, does it mean that I 
> have to manually set the variables (such as form.vars.var1, etc) to the 
> individual fields if I use custom HTML page with custom CSS layout?
>


[web2py] Re: advice and help on csv input

2012-06-29 Thread song
db.define_table('state',
Field('iso','string'),
#Field('country_iso',db.country),
Field('code','string'),
Field('name','string'),
Field('level','string')
)
I correct  db. like above



2012년 6월 30일 토요일 오후 1시 6분 43초 UTC+9, song 님의 말:
>
> Nowdays I study the web2py.
> I met the problems for me only.
> By the appadmin.py, the database was constructed.
> Then at the 'state' , there are problemes in the CSV import.
>
> db files
>
> #
> db.define_table('country',
> Field('name', unique=True),
> Field('iso'),
> Field('numcode')
> )
>
> db.define_table('state',
> Field('country_iso',db.country),
> Field('subcountry_code','string'),
> Field('name','string'),
> Field('subcountry_level','string')
> )
>
> db.country.name.requires = IS_NOT_IN_DB(db,db.country.name)
> db.country.name.requires = IS_NOT_EMPTY()
>
> db.state.name.requires = IS_NOT_EMPTY()
> db.state.country_iso.requires = IS_IN_DB(db, db.country.iso,'%(iso)s')
>
> and csv files
>
> name,iso,numcode
> Afghanistan,AF,4
> Albania,AL,8
> Algeria,DZ,12
> American Samoa,AS,16
> Andorra,AD,20
> Angola,AO,24
> Anguilla,AI,660
> Antarctica,AQ,10
> Antigua and Barbuda,AG,28
> Argentina,AR,32
> Armenia,AM,51
> Aruba,AW,533
> Australia,AU,36
> Austria,AT,40
> Azerbaijan,AZ,31
> Bahamas,BS,44
> Bahrain,BH,48
> Bangladesh,BD,50
> Barbados,BB,52
> Belarus,BY,112
> Belgium,BE,56
> Belize,BZ,84
> Benin,BJ,204
> Bermuda,BM,60
> Bhutan,BT,64
>
>
> country_iso,subcountry_code,name,subcountry_level
> AD,AN,Andorra la Vella,NULL
> AD,CA,Canillo,NULL
> AD,EE,Escaldes-Engordany,NULL
> AD,EN,Encamp,NULL
> AD,JL,Sant Julià de Lòria,NULL
> AD,MA,La Massana,NULL
> AD,OR,Ordino,NULL
> AE,AJ,Ajman,NULL
> AE,AZ,Abu Z¸aby [Abu Dhabi],NULL
> AE,DU,Dubayy [Dubai],NULL
> AE,FU,Al Fujayrah,NULL
> AE,RK,Ras al Khaymah,NULL
> AE,SH,Ash Shariqah [Sharjah],NULL
> AE,UQ,Umm al Qaywayn,NULL
> AF,BAL,Balkh,NULL
> AF,BAM,Bamian,NULL
> AF,BDG,Badghis,NULL
> AF,BDS,Badakhshan,NULL
> AF,BGL,Baghlan,NULL
> AF,FRA,Farah,NULL
>
> Which parts are modified for corrected input?
>
>

[web2py] Re: response.menu problem

2012-06-29 Thread Annet
Hi Anthony,

Thanks for your reply. I have stored the cms_menu in session. The only 
problem is that, whether menu items are displayed or not is set in a 
function, which is executed after menu.py. I solved the problem by not 
showing that part of the cms-menu in the functions view. That works for now.


Kind regards,

Annet


[web2py] Getting auth.settings.register_next to work...

2012-06-29 Thread Doug Philips
I've been customizing how registration works for my app as a few of my
app's users are getting confused by the registration verification
email.
Ok, so I will just have my app send them to a nice hand-holding
explanatory page after they've submitted their registration
information.

According to The Book, "all" I have to do is set
auth.settings.register_next to the URL I want, and I'm good to go.
But I can't get that to work.

(all line numbers are for
https://github.com/web2py/web2py/blob/master/gluon/tools.py as of the
time of this message)

First off, it seems that the Register link I get from auth.navbar()
always has a _next parameter appended to it,
and that _next seems to override anything I set in my model for
auth.settings.registration_next.
Fine, I go into the navbar function of the Auth class in tools.py and
delete the "+next" part of the registration link. (line 1242)
That doesn't work, as for some reason I don't understand, the ?_next
parameter in the URL is still present when the navbar is constructed
from a regular page, but the ?_next parameter is (properly) missing
from Register link when I first click on Login. Very odd to me.

After trying a few more fixes, I decide that I do not understand how
next processing is done for Auth.
My fix is a huge hammer.
I go into the register function and change lines 1983 and 1984.
Actually I delete them and replace them with:
next = self.settings.register_next

I have no idea what the lines I deleted are trying to do, but they
were keeping my expressed intent from working.
Now my users are directed to the page I want after submitting their
registrations, but I have no idea what else I have subtly screwed up.
I don't even know if I should submit a bug report or if there is some
other configuration I could do that would avoid having to make this
code change.
Help!

-Doug


[web2py] Re: Getting auth.settings.register_next to work...

2012-06-29 Thread Doug Philips
On Sat, Jun 30, 2012 at 2:37 AM, I wrote:
> and that _next seems to override anything I set in my model for
> auth.settings.registration_next.

Typo, I should have written:
and that _next parameter seems to override anything I set in my model
for auth.settings.register_next

-=D