[web2py] Database auditing - comments please

2011-07-22 Thread nick name
Attached you'll find my first go at a database audit module for web2py. It 
will log every change to a table. The crud versioning system is nice, but it 
only versions stuff that happens on crud. If you insert/modify records not 
through crud, you'd need to manually update it -- the attached code will do 
that automatically for you.

The app I'm developing needs a searchable, browseable audit of all changes 
to database, for which simple SQL logging is not sufficient.

WARNING: only very lightly tested code, probably doing everything the wrong 
way. Use at your own risk.

To use: place audit.py in your models directory; then, after defining a 
table with 

mytable = db.define_table('mytable', )

call:

with_audit(mytable)

It will create a table called 'audit_mytable', which has in addition to all 
your fields, 4 more: oid (original id), time, user, and action 
(insert/update/delete)

any modification to the original table will result in a record being added; 
inserted records are copied after insertion; updated records are copied 
after update; deleted records are copied before delete.

KNOWN ISSUES:
* audit table is placed on the same adapter as the audited table - I want to 
allow the audit to be on a different db/dal/adapter (needs distributed 
transaction to work properly!)
* old id is always integer for lack of a better type; it should be a weak 
reference type
* reference types are still reference type, so when deleting linked records, 
on delete cascade will remove audit records, this is bad! other integrity 
constraints (notnull, validators etc.) are not copied to audit table -- only 
references.
* action type is int, no way to specify efficient char(1) in web2py
* audit happens within same transaction as original update, so you commit or 
rollback both -- I think that's expected behaviour.
* On first use, it patches the adapter *class*. This means that, unlike 
usual web2py debugging, if you edit audit.py, you'll have to restart web2py. 
Writing it now, I can't think of a good reason why I did that rather than 
patch the adapter *instance* -- but that's the case for the attached code.

A better solution would probably be to add pre/post hooks to 
insert/update/delete in BaseAdapter, but for now the audit.py approach seems 
to work on 1.95 - 1.97
#
# General audit support for web2py:
#  When a table is set to be audited, a shadow table is defined for
#  it, with 3 additional fields: oid (for original id), audit_time, audit_user, audit_type (insert/update/delete)
# on insert: after insert, the new record is copied to audit table
# on update: after update, the new records are copied to the audit table
# on delete: before deleting, records are copied to the audit table with audit_delete=true
# 
# no new/additional transactions. that is, rollback will also roll back the audit; commit
# will also commit the audit.

# TODO: deactivate on delete cascade actions - turn them to restrict or even drop the reference?
# TODO: add idtype to adapter - a type that can be used to store id - a weak reference
# TODO: is there a char(1) record type? audit_type would benefit from that

class AuditError(RuntimeError): 
pass

AUDIT_OID = Field(audit_oid, integer) # - switch to idtype/weak reference
AUDIT_TIME = Field(audit_time, datetime)
AUDIT_USER = Field(audit_user, string) # or auth_user
AUDIT_TYPE  = Field(audit_type, integer) # 1=insert, 2=update, 3=delete 
AUDIT_FIELDS = [AUDIT_OID, AUDIT_TIME, AUDIT_USER, AUDIT_TYPE]

AUDIT_TYPE_INSERT = 1
AUDIT_TYPE_UPDATE = 2
AUDIT_TYPE_DELETE = 3
AUDIT_TEMPLATE = 'audit_%s'

def audited_record(shadow, record, audit_type):
Make a record into the audit record with a given type in place
record[AUDIT_OID.name] = record.id
del record['id'] # audit records gets their own id
del record['update_record'] # since we retrieve id, we get this ?!!?
del record['delete_record'] # since we retrieve id, we get this ?!?!
record[AUDIT_TIME.name] = request.now
record[AUDIT_USER.name] = 'unknown'
record[AUDIT_TYPE.name] = audit_type
shadow.insert(**record)


def audited_insert(self, table, fields):
shadow = self.shadow.get(table._tablename)
if not shadow: return self.unaudited_insert(table, fields)

rid = self.unaudited_insert(table, fields)
if isinstance(rid, int): # either int or Reference
record = table[int(rid)] # retrieve just inserted record
audited_record(shadow, record, AUDIT_TYPE_INSERT)
return rid
raise AuditError, Cannot audit inserts to table %s%table

# TODO: how do we audit a change to id? should we block it?
def audited_update(self, tablename, query, fields):
shadow = self.shadow.get(tablename)
if not shadow: return self.unaudited_update(tablename, query, fields)
db = self.db
table = db[tablename]

# find which records are about to be updated by this 
rows = self.select(query, ['id'], {})
rows = [x['id'] for x in rows] # we only care about the ids.
   

Re: [web2py] Re: upgrading from 1.95.1 to 1.96.1 breaks cross app authentication

2011-07-22 Thread Heng Zeng Aun
Good day Massimo,

the following are the snippets:

 AppAuth/models/db.py 
db = DAL('sqlite://storage.sqlite')
session.connect(request, response, db)
auth = Auth(globals(), db)
crud = Crud(globals(), db)
auth.settings.hmac_key = 'sha512:secret key here'
auth.define_tables(username=True)
crud.settings.auth = auth

 AppA/models/db.py 
db = DAL('sqlite://../../appauth/storage.sqlite') # -- yes, point to the db
file in AppAuth
session.connect(request, response, db, masterapp='appauth')
auth = Auth(globals(), db)
auth.define_tables(migrate=False, username=True)
auth.settings.login_url = '/appauth/default/user/login'

 AppA/controllers/default.py 
@auth.requires_login()
def index():
response.view='index.html'
return dict()

@auth.requires_permission('sayhello')
def hello():
response.view='saysomething.html'
return dict(message=T(hello))


The behavior of this in 1.96.1 (and 1.97.1) is that I will be able to login
and view the page provided in AppAuth, but when browse to AppA or AppB, it
will not be able to access it because auth says its not loggin. However all
this works in 1.95.1

If i go into web2py.gluon.tools.Auth and hack current to current =
Storage(globals()) like it used to be in 1.95.1, and things works again.

I'm sure forcing current from threading.local() to something else
definitely is not the correct way of doing this (as i dont know what is the
intention of the current is using for as well : ).

Awaits your input, Many Thanks Massimo.

best,
Zeng

On Thu, Jul 21, 2011 at 8:44 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 This change should not break it. Can you please show us the code that
 breaks and we will check what is going on? It is possible that one of
 the auth modules has not been patched correctly.

 Massimo

 On Jul 21, 11:02 am, zeng zeng...@gmail.com wrote:
  Hey guys,
 
  I'm currently running version 1.95.1 and have 3 application,
  AppAuth, AppA, AppB, AppA and AppB is using AppAuth to
  authenticate logged in user and it has been working great.
 
  After upgrading 1.96.1 and cross app authentication no longer works,
  some debuging lead to:
  - web2py.gluon.tools.Auth 
  self.environment = current
  request = current.request
  session = current.session
  - web2py.gluon.tools.Auth 
 
  and current is a threading.local() in gluon.globals.py !!!
 
  In the good'o 1.95.1 the session and auth object is retrieved from
  global() ,
 
  Question is, why is this changed? this seems to break the backward
  compatibility feature of web2py, and what are the recommended
  solutions now that global() is no longer used?
 
  Thanks!



Re: [web2py] deploying web2py app on gae

2011-07-22 Thread Bruno Rocha
How is your app.yaml ?


[web2py] jQuery templates

2011-07-22 Thread guruyaya
I am trying to start using jQuery templates on something, but it
creates a problem.
jQuery templates use the {{ }} syntax to do a lot of tasks. Web2py
too. I can use another delimiter on web2py, but that will force me to
change the syntax for all my templates, because the template I'm
working with, extends the main theme. Which means I can either change
the main theme, web2py_ajax and so on, to use {% %} and make all the
other templates in the project conform to it, or find a way to make
jQuery template change it's delimiter. I tried writing the template
code inside an XML tag:
 XML(
{{YAYA}}
)

, but it gives me this exception:
.
.
.
  File /home/guruyaya/sat/web2py/applications/locwall/views/default/
index.html, line 105
response.write(XML('''
{{YAYA)
response.write(\n''')}}\n, escape=False)


   ^
SyntaxError: invalid syntax


Is there any other way I can do that?
Thanks in advance
YAYA


[web2py] Re: Web2py Powertables plugin : in-line editing problem.

2011-07-22 Thread Will
I just saw your new pre-alpha plugin PowerGrid and maybe an editing
button in a separate column like it has would be better, especially if
an onvalidation=... validator can be applied to the generated form in
the popup.
Does PowerTable has the same function included or is in-line editing
the only 'ready-for-use' editing in the plugin ?


Re: [web2py] jQuery templates

2011-07-22 Thread Bruno Rocha
I am using Jquery templates for PowerGrid[0] and I have no problem.


example:
script id=template type=text/x-jquery-tmpl
   div
  div${name}/div
  div${email}/div

  div class=gridy-button
 a href=#edit/a
  /div
/div
/script

Look it working: http://labs.blouweb.com/PowerGrid/default/index

On Fri, Jul 22, 2011 at 4:35 AM, guruyaya guruy...@gmail.com wrote:

 I am trying to start using jQuery templates on something, but it
 creates a problem.
 jQuery templates use the {{ }} syntax to do a lot of tasks. Web2py
 too. I can use another delimiter on web2py, but that will force me to
 change the syntax for all my templates, because the template I'm
 working with, extends the main theme. Which means I can either change
 the main theme, web2py_ajax and so on, to use {% %} and make all the
 other templates in the project conform to it, or find a way to make
 jQuery template change it's delimiter. I tried writing the template
 code inside an XML tag:
  XML(
 {{YAYA}}
 )

 , but it gives me this exception:
 .
 .
 .
  File /home/guruyaya/sat/web2py/applications/locwall/views/default/
 index.html, line 105
response.write(XML('''
 {{YAYA)
 response.write(\n''')}}\n, escape=False)


   ^
 SyntaxError: invalid syntax


 Is there any other way I can do that?
 Thanks in advance
 YAYA




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] jQuery templates

2011-07-22 Thread Bruno Rocha
I got the diiffs

HTML encoding

Using {{html fieldNameOrExpression}} is equivalent to using
${fieldNameOrExpression}, except that it renders unencoded text into the
HTML DOM, whereas ${} encodes values by default.

On Fri, Jul 22, 2011 at 4:56 AM, Bruno Rocha rochacbr...@gmail.com wrote:

 I am using Jquery templates for PowerGrid[0] and I have no problem.


 example:
 script id=template type=text/x-jquery-tmpl
div
   div${name}/div
   div${email}/div

   div class=gridy-button
  a href=#edit/a
   /div
 /div
 /script

 Look it working: http://labs.blouweb.com/PowerGrid/default/index

 On Fri, Jul 22, 2011 at 4:35 AM, guruyaya guruy...@gmail.com wrote:

 I am trying to start using jQuery templates on something, but it
 creates a problem.
 jQuery templates use the {{ }} syntax to do a lot of tasks. Web2py
 too. I can use another delimiter on web2py, but that will force me to
 change the syntax for all my templates, because the template I'm
 working with, extends the main theme. Which means I can either change
 the main theme, web2py_ajax and so on, to use {% %} and make all the
 other templates in the project conform to it, or find a way to make
 jQuery template change it's delimiter. I tried writing the template
 code inside an XML tag:
  XML(
 {{YAYA}}
 )

 , but it gives me this exception:
 .
 .
 .
  File /home/guruyaya/sat/web2py/applications/locwall/views/default/
 index.html, line 105
response.write(XML('''
 {{YAYA)
 response.write(\n''')}}\n, escape=False)


   ^
 SyntaxError: invalid syntax


 Is there any other way I can do that?
 Thanks in advance
 YAYA




 --



 --
 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]



Re: [web2py] Re: Web2py Powertables plugin : in-line editing problem.

2011-07-22 Thread Bruno Rocha
PowerTable is being rewriten, for lots of improvements and no
more dependency on SQLTABLE.

By now, in powertable the only out-of-box option for edit is inline editing,
or you can load an IFRAME(CRUD) form in details and edit records there.

Optionally you can use VirtualFields to append new buttons to the table, so
the button will have JavaScript needed to load a modal box or popup passing
its parent TR id attr.

PowerGrid is being very tested and it is going from alpha to beta, the best
option for crud based data grid is PowerGrid.

I am going to release a new version this weekend (
http://labs.blouweb.com/PowerGrid/default/noimages)

PowerTable rewriten will take one or two months to be ready.

Tks

On Fri, Jul 22, 2011 at 4:41 AM, Will g2g.gir...@gmail.com wrote:

 I just saw your new pre-alpha plugin PowerGrid and maybe an editing
 button in a separate column like it has would be better, especially if
 an onvalidation=... validator can be applied to the generated form in
 the popup.
 Does PowerTable has the same function included or is in-line editing
 the only 'ready-for-use' editing in the plugin ?



[web2py] jquery mobile switch in view

2011-07-22 Thread andrej burja
hi

is it possible to create a site with a switch like chosing a language 
(http://vimeo.com/7520812)
but instead of language i would like to select which version of a view i 
woul like to see: desktop or mobile
so the first line in i view would be:
extend layout.html
or
extend plugin_jqmobile/layout.html

as i know i can not put {{extend ... inside if statement
and {{extend ... should bee the first statement

andrej


[web2py] Web2py Certification Program ?

2011-07-22 Thread António Ramos
Hello,

Why not create a web2py certification program?
It would be good for the programmer and for web2py

Thank you
António


[web2py] Re: jquery mobile switch in view

2011-07-22 Thread David Marko
The {{extend }} can use variable as parameter so you can, under ome 
conditions, compute template name and store it into response object(you can 
place such code in model)
e.g.
response.template=layoutjq.html 

... and in a view use the following:
{{extend response.template}}


Re: [web2py] Web2py Certification Program ?

2011-07-22 Thread Bruno Rocha
I've been working together with Latinux.org to create a web2py/python
certification program, but the project is closed (I guess).

IMO. We need a web2py foundation first.

2011/7/22 António Ramos ramstei...@gmail.com

 Hello,

 Why not create a web2py certification program?
 It would be good for the programmer and for web2py

 Thank you
 António







-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] Re: Tiny example on uwsgidecorators+web2py

2011-07-22 Thread Tiago Moutinho
thks Roberto,

tiago@tiago:~$ cd /opt/web2py/
tiago@tiago:/opt/web2py$ mkdir myspool
tiago@tiago:/opt/web2py$ uwsgi --socket :3031 --spooler myspool --
master --processes 4 --import mytasks --module web2py.wsgihandler
uwsgi: unrecognized option '--import'


On Jul 22, 5:47 am, Roberto De Ioris robe...@unbit.it wrote:
  How can i create the spoller directory?

 mkdir myspool

 It is a normal, empty directory











  thks in advance

  On Jul 21, 6:06 pm, Roberto De Ioris robe...@unbit.it wrote:
   Hello Roberto,

   I've tried to start web2py has you demonstrated:

   uwsgi --socket :3031 --spooler myspool --master --processes 4 --
   import mytasks --module web2py.wsgihandler

   but I got this error:

   [spooler directory] access(): No such file or directory [uwsgi.c
   line 2994]

   What is wrong?

  the spooler directory must exists (it is a security measure)

  --
  Roberto De Iorishttp://unbit.it

 --
 Roberto De Iorishttp://unbit.it


Re: [web2py] Re: Tiny example on uwsgidecorators+web2py

2011-07-22 Thread Roberto De Ioris

Il giorno 22/lug/2011, alle ore 11:09, Tiago Moutinho ha scritto:

 thks Roberto,
 
 tiago@tiago:~$ cd /opt/web2py/
 tiago@tiago:/opt/web2py$ mkdir myspool
 tiago@tiago:/opt/web2py$ uwsgi --socket :3031 --spooler myspool --
 master --processes 4 --import mytasks --module web2py.wsgihandler
 uwsgi: unrecognized option '--import'
 
 



Are you using the latest stable release ?

--import was added in 0.9.8.2 (there are other ways to implement this in 
0.9.8.1 but --import
is so handy that the upgrade is worthy :) )

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



[web2py] blogs

2011-07-22 Thread hasan alnator
hello guys ,
 am trying to build a blogs website but i want to have a video and
image upload in every post so its not just text  but  i dont know how
to use an uploaded file in the pages and i tryed to use flash video
plugin it dosent see any video out of the static folder  ..  please
help me guys

  thank u all


[web2py] Re: Simultaneous multi-language system.

2011-07-22 Thread jamarcer
Hello:

I have added a comment to the ticket, explaining an approach to this
issue.

It is based on Anthony's proposal, as demetrio said :).

I am demetrio's companion, so I will test this approach, or others
possible solutions.

Regards.

Link to ticket: http://code.google.com/p/web2py/issues/detail?id=342


On 21 jul, 10:16, Daniel Gonzalez Zaballos dgzabal...@gmail.com
wrote:
 i'll start with the Anthony suggestion.
 I've opened the ticket:http://code.google.com/p/web2py/issues/detail?id=342

 Thank you to everybody

 2011/7/21 Massimo Di Pierro massimo.dipie...@gmail.com







  I think for now Anthony's proposal is the way to go. Open a ticket in
  google code and we can think of other options.

  On Jul 20, 5:53 pm, Anthony abasta...@gmail.com wrote:
   I think there are a few possibilities. First, your MultiT function could
   work, but you'd have to use str(T(text)) instead of T(text). The reason
  is
   that T() returns a lazyT object, not the translated string (it isn't
   translated until rendering). You can force the translation by calling the
   lazyT.__str__ method via str(T(text)).

   Another option is to define your own T() objects for each language and
  force
   them to use the specific language. For example:

   In a model file:
   from gluon.languages import translator
   enT=translator(request)
   enT.force('en-en')
   esT=translator(request)
   esT.force('es-es')

   In a view:
   {{=esT('House')}} / {{=enT('House')}}

   It would probably be easy to abstract the above by defining a class that
   stores multiple T objects and lets you easily add additional ones.

   A third option might be to create a special multi-language translation
  file.
   For example, you could create a file called es-en.py, which could include
   translations such as:

   'House': 'Casa / House'

   Hope that helps.

   Anthony

   On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote:
Hi everyone, i don't know if Simultaneous multi-language system is
the correct way to say what i need... i'll explain myself.

I'm developing an application that by request of our customer, needs
to have 2 languages at the same time. For example, if this app were in
spanish and english, in the navigator should appear something like:

Casa / House

In the view we want to do something like this

{{=T(House, es-es)}} / {{=T(House, en-en)}}

But i don't know if web2py can permit to do this or something like
that.

I was thinking of writing a function like this:

def MultiT(text,separator= / ):
    T.force(es-es)
    ret_text = T(text)
    T.force(en-en)
    ret_text += separator + T(text)
    return ret_text

But it does not work. Also, do not know how this affects the system
when updating the language files with the strings to translate (now
the files are updated automatically when pressing the update
languages button in admin, and I guess that it would make it on run
time.

Any sugestions?

Best regards
Daniel


[web2py] [Newbie] Best practice to set application wide settings

2011-07-22 Thread Jagmal
Hi All,

I am new to web2py framework and have been working on a small project
to set up authentication. In here, I would like to configure default
options. For ex, I would like to disable registration. I am wondering
what is a good way to do it.

Should I create a model class and put these default settings there?
Also, should I be using the same model class to configure DB and other
application wide settings?

Regards,
Jagmal


[web2py] Re: Simultaneous multi-language system.

2011-07-22 Thread jamarcer
Hello:

I have added a comment to the ticket:

http://code.google.com/p/web2py/issues/detail?id=342

It is an approach to the issue, based in Anthony's proposal: a class
that stores multiple T objects.

I am demetrio's companion. We develop the same application, but we
have different roles :), so I will test this approach, and other
possible solutions.

Regards.

On 21 jul, 10:16, Daniel Gonzalez Zaballos dgzabal...@gmail.com
wrote:
 i'll start with the Anthony suggestion.
 I've opened the ticket:http://code.google.com/p/web2py/issues/detail?id=342

 Thank you to everybody

 2011/7/21 Massimo Di Pierro massimo.dipie...@gmail.com







  I think for now Anthony's proposal is the way to go. Open a ticket in
  google code and we can think of other options.

  On Jul 20, 5:53 pm, Anthony abasta...@gmail.com wrote:
   I think there are a few possibilities. First, your MultiT function could
   work, but you'd have to use str(T(text)) instead of T(text). The reason
  is
   that T() returns a lazyT object, not the translated string (it isn't
   translated until rendering). You can force the translation by calling the
   lazyT.__str__ method via str(T(text)).

   Another option is to define your own T() objects for each language and
  force
   them to use the specific language. For example:

   In a model file:
   from gluon.languages import translator
   enT=translator(request)
   enT.force('en-en')
   esT=translator(request)
   esT.force('es-es')

   In a view:
   {{=esT('House')}} / {{=enT('House')}}

   It would probably be easy to abstract the above by defining a class that
   stores multiple T objects and lets you easily add additional ones.

   A third option might be to create a special multi-language translation
  file.
   For example, you could create a file called es-en.py, which could include
   translations such as:

   'House': 'Casa / House'

   Hope that helps.

   Anthony

   On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote:
Hi everyone, i don't know if Simultaneous multi-language system is
the correct way to say what i need... i'll explain myself.

I'm developing an application that by request of our customer, needs
to have 2 languages at the same time. For example, if this app were in
spanish and english, in the navigator should appear something like:

Casa / House

In the view we want to do something like this

{{=T(House, es-es)}} / {{=T(House, en-en)}}

But i don't know if web2py can permit to do this or something like
that.

I was thinking of writing a function like this:

def MultiT(text,separator= / ):
    T.force(es-es)
    ret_text = T(text)
    T.force(en-en)
    ret_text += separator + T(text)
    return ret_text

But it does not work. Also, do not know how this affects the system
when updating the language files with the strings to translate (now
the files are updated automatically when pressing the update
languages button in admin, and I guess that it would make it on run
time.

Any sugestions?

Best regards
Daniel


[web2py] Re: database replication

2011-07-22 Thread Nils Olofsson
Hi,
I'm still not sure as to how to go about using this.

Say, I have a controller with the function list: and a function called
write:

if the function is list then read from slaves, if the function is
write, write to master.

So the correct code should be:

if request.function in read_only_action:
db =... ...
else
db = 
 and this is in the model/db.py file.

I just don't understand where to define read_only_action or it is
used ?

Regards,

Nils

On Jul 21, 9:16 pm, Anthony abasta...@gmail.com wrote:
 That's just some (incomplete) example code. You have to define
 'read_only_actions' yourself. In that example, it would be a list functions
 that only need to read (but not write) the database and can therefore be
 given access to one of the slave databases.

 Actually, it looks like the code has an error -- it should say
 request.function, not request.action -- I'll make the change.

 Anthony







 On Thursday, July 21, 2011 3:54:20 PM UTC-4, Nils Olofsson wrote:
  Hi,

  I did this but i got :

  Traceback (most recent call last):
    File /var/www/web2py/gluon/restricted.py, line 192, in restricted
      exec ccode in environment
    File /var/www/web2py/applications/Event/models/db.py, line 18, in
  module
      if request.action in read_only_actions:
  NameError: name 'read_only_actions' is not defined

  type 'exceptions.NameError'(name 'read_only_actions' is not defined)

  This error is the reason i asked where it should go.

  Maybe some one could shed some light on it ?

  Regards,
  Nils

  On Jul 21, 7:44 pm, Anthony abas...@gmail.com wrote:
   It would go in your model file -- the same place where you would normally

   define the db connection.

   Anthony

   On Thursday, July 21, 2011 2:29:45 PM UTC-4, Nils Olofsson wrote:
Hi Massimo,

I'm testing amazon's RDS and EC2 , 1 master many slaves.

I could not find out where exactly I am suppose to be putting this
code.

Regards,

Nils

On Jul 21, 6:48 pm, Massimo Di Pierro massi...@gmail.com
wrote:
 You would only use this if you have a replicated database. I.e. you
 are running many database servers synced with each other. For
  example:
   http://en.wikipedia.org/wiki/Multi-master_replication

 On Jul 21, 12:44 pm, Nils Olofsson nils...@gmail.com wrote:

  Hi,

  I see this in the Documentation:

  if request.action in read_only_actions:
     db =
  DAL(shuffle(['mysql://...1','mysql://...2','mysql://...3']))
  else:
     db =
  DAL(shuffle(['mysql://...3','mysql://...4','mysql://...5']))

  I'm not sure where exactly I should be using this ?

  And does anyone have some sample code as to how it should be used ?

  Nils


Re: [web2py] Web2py Certification Program ?

2011-07-22 Thread Miguel Lopes
There is some private offering, which I think should be listed in web2py.com
:

* a program at DePaul University:
http://www.cdm.depaul.edu/ipd/Programs/Pages/WebDevelopmentwithPython.aspx
* a program in Brasil: http://www.cursodepython.com.br/

And free courses (structured content, besides the www.web2py.com/book)
* in Brasil too (go Brasil!):
http://web2pybrasil.appspot.com/init/plugin_wiki/page/curso-web2py-000

The DePaul program page doesn't mention web2py, but the program used to be
done with web2py, and I guess still is (the word is that  Massimo used to be
the instructor :-)

HTH

2011/7/22 António Ramos ramstei...@gmail.com

 Hello,

 Why not create a web2py certification program?
 It would be good for the programmer and for web2py

 Thank you
 António







Re : Re: [web2py] Re: Web2py Powertables plugin : in-line editing problem.

2011-07-22 Thread JmiXIII
Hello ,


PowerGrid seems pretty nice and usefull, yet powertable fits better my 
needs. I've used the details to render other view containing forms and it's 
Ok for me.
Yet is Powergrid intended to replace PowerTable or will you work on both 
project? That's just to know which plugin to choose for my work.
I do understand it's a hard job to maintain it and thank you for the job you 
share.



Re: [web2py] blogs

2011-07-22 Thread Kenneth Lundström

Hello,

have you read:
http://web2py.com/book/default/chapter/07?search=upload#SQLFORM-and-Uploads

Do you get any error messages when using the flash plugin?


Kenneth


hello guys ,
  am trying to build a blogs website but i want to have a video and
image upload in every post so its not just text  but  i dont know how
to use an uploaded file in the pages and i tryed to use flash video
plugin it dosent see any video out of the static folder  ..  please
help me guys

   thank u all




[web2py] Admin is disabled because insecure channel

2011-07-22 Thread António Ramos
i´m trying to access my server from another machine.

i started web2py with this command line

c:\web2py\web2py.exe -i 192.168.1.8


How to solve it?



thank you
António


[web2py] Re: database replication

2011-07-22 Thread Anthony
You could define 'read_only_actions' anywhere it makes sense, for example:
 
read_only_actions = ['list','another_read_action','yet_another_read_action']
if request.function in read_only_actions: 
db =... ... 
else 
db =  
 
Of course, if that one 'if' statement is the only place you refer to 
'read_only_actions', then there's no need to define it as a separate 
variable -- you could just put the list right in the 'if' statement. I think 
'read_only_actions' was used in the book example just to indicate the idea 
that you would use the slave databases for actions that don't need to write 
to the db -- it's just a stand-in for an actual list of such actions.
 
Anthony
 

On Friday, July 22, 2011 6:50:31 AM UTC-4, Nils Olofsson wrote:

 Hi, 
 I'm still not sure as to how to go about using this. 

 Say, I have a controller with the function list: and a function called 
 write: 

 if the function is list then read from slaves, if the function is 
 write, write to master. 

 So the correct code should be: 

 if request.function in read_only_action: 
 db =... ... 
 else 
 db =  
  and this is in the model/db.py file. 

 I just don't understand where to define read_only_action or it is 
 used ? 

 Regards, 

 Nils 

 On Jul 21, 9:16 pm, Anthony abas...@gmail.com wrote: 
  That's just some (incomplete) example code. You have to define 
  'read_only_actions' yourself. In that example, it would be a list 
 functions 
  that only need to read (but not write) the database and can therefore be 
  given access to one of the slave databases. 
  
  Actually, it looks like the code has an error -- it should say 
  request.function, not request.action -- I'll make the change. 
  
  Anthony 
  
  
  
  
  
  
  
  On Thursday, July 21, 2011 3:54:20 PM UTC-4, Nils Olofsson wrote: 
   Hi, 
  
   I did this but i got : 
  
   Traceback (most recent call last): 
 File /var/www/web2py/gluon/restricted.py, line 192, in restricted 
   exec ccode in environment 
 File /var/www/web2py/applications/Event/models/db.py, line 18, in 
   module 
   if request.action in read_only_actions: 
   NameError: name 'read_only_actions' is not defined 
  
   type 'exceptions.NameError'(name 'read_only_actions' is not defined) 
  
   This error is the reason i asked where it should go. 
  
   Maybe some one could shed some light on it ? 
  
   Regards, 
   Nils 
  
   On Jul 21, 7:44 pm, Anthony aba...@gmail.com wrote: 
It would go in your model file -- the same place where you would 
 normally 
  
define the db connection. 
  
Anthony 
  
On Thursday, July 21, 2011 2:29:45 PM UTC-4, Nils Olofsson wrote: 
 Hi Massimo, 
  
 I'm testing amazon's RDS and EC2 , 1 master many slaves. 
  
 I could not find out where exactly I am suppose to be putting this 
 code. 
  
 Regards, 
  
 Nils 
  
 On Jul 21, 6:48 pm, Massimo Di Pierro mass...@gmail.com 
 wrote: 
  You would only use this if you have a replicated database. I.e. 
 you 
  are running many database servers synced with each other. For 
   example: 
http://en.wikipedia.org/wiki/Multi-master_replication 
  
  On Jul 21, 12:44 pm, Nils Olofsson nil...@gmail.com wrote: 
  
   Hi, 
  
   I see this in the Documentation: 
  
   if request.action in read_only_actions: 
  db = 
   DAL(shuffle(['mysql://...1','mysql://...2','mysql://...3'])) 
   else: 
  db = 
   DAL(shuffle(['mysql://...3','mysql://...4','mysql://...5'])) 
  
   I'm not sure where exactly I should be using this ? 
  
   And does anyone have some sample code as to how it should be 
 used ? 
  
   Nils



Re: Re : Re: [web2py] Re: Web2py Powertables plugin : in-line editing problem.

2011-07-22 Thread Bruno Rocha
I will maintain both plugins. (but not so fast to update and solve issues)

http://labs.blouweb.com

On Fri, Jul 22, 2011 at 8:33 AM, JmiXIII sylvn.p...@gmail.com wrote:

 Hello ,


 PowerGrid seems pretty nice and usefull, yet powertable fits better my
 needs. I've used the details to render other view containing forms and it's
 Ok for me.
 Yet is Powergrid intended to replace PowerTable or will you work on both
 project? That's just to know which plugin to choose for my work.
 I do understand it's a hard job to maintain it and thank you for the job
 you share.




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] Admin is disabled because insecure channel

2011-07-22 Thread Bruno Rocha
Use https or change security checks at your own risk in
applications/admin/models 0.py and access.py.

2011/7/22 António Ramos ramstei...@gmail.com

 i´m trying to access my server from another machine.

 i started web2py with this command line

 c:\web2py\web2py.exe -i 192.168.1.8


 How to solve it?



 thank you
 António




--


Re: [web2py] [Newbie] Best practice to set application wide settings

2011-07-22 Thread Bruno Rocha
The best practice says that:

1. have the latest web2py version
2. create your classes and custom objects in /modules
3. create in /modules a class to hold your settings properties or use
gluon.storage.Storage
4. In models import your modules with your classes and objects (you can use
'current' object to pass data between models and modules)
5. define database tables in models (models are executed alphabetically)
6. Use controllers only do determine the control flow of app, complex code
go to /modules and instantiate/call in controller/model
7. Many HTML HELPERS in controllers
8. Less HTML HELPERS in views
9. take care about security defining the response.generic_patterns and
proper authentication/siganature
10. READ THE BOOK (but not only the book, the source code, the group)



On Fri, Jul 22, 2011 at 2:54 AM, Jagmal jag...@gmail.com wrote:

 Hi All,

 I am new to web2py framework and have been working on a small project
 to set up authentication. In here, I would like to configure default
 options. For ex, I would like to disable registration. I am wondering
 what is a good way to do it.

 Should I create a model class and put these default settings there?
 Also, should I be using the same model class to configure DB and other
 application wide settings?

 Regards,
 Jagmal




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] Re: database replication

2011-07-22 Thread Nils Olofsson
Hi, I did something similar,

if add in request.function:
   db = DAL(['mysql://Database connection string'])
else:
   print Using Slave Database
   db = DAL(shuffle(['database connection string'])

That would and uses the slave database (readonly) but, I get this
error message.

InternalError: (1290, u'The MySQL server is running with the --read-
only option so it cannot execute this statement')

bar this function add and auth all other functions read data.
I looked around at the DAL code and could not find a way to tell the
DAL that mysql is read only.
any ideas ?

Regards,

Nils


On Jul 22, 1:58 pm, Anthony abasta...@gmail.com wrote:
 You could define 'read_only_actions' anywhere it makes sense, for example:

 read_only_actions = ['list','another_read_action','yet_another_read_action']
 if request.function in read_only_actions:
     db =... ...
 else
     db = 

 Of course, if that one 'if' statement is the only place you refer to
 'read_only_actions', then there's no need to define it as a separate
 variable -- you could just put the list right in the 'if' statement. I think
 'read_only_actions' was used in the book example just to indicate the idea
 that you would use the slave databases for actions that don't need to write
 to the db -- it's just a stand-in for an actual list of such actions.

 Anthony







 On Friday, July 22, 2011 6:50:31 AM UTC-4, Nils Olofsson wrote:
  Hi,
  I'm still not sure as to how to go about using this.

  Say, I have a controller with the function list: and a function called
  write:

  if the function is list then read from slaves, if the function is
  write, write to master.

  So the correct code should be:

  if request.function in read_only_action:
      db =... ...
  else
      db = 
   and this is in the model/db.py file.

  I just don't understand where to define read_only_action or it is
  used ?

  Regards,

  Nils

  On Jul 21, 9:16 pm, Anthony abas...@gmail.com wrote:
   That's just some (incomplete) example code. You have to define
   'read_only_actions' yourself. In that example, it would be a list
  functions
   that only need to read (but not write) the database and can therefore be
   given access to one of the slave databases.

   Actually, it looks like the code has an error -- it should say
   request.function, not request.action -- I'll make the change.

   Anthony

   On Thursday, July 21, 2011 3:54:20 PM UTC-4, Nils Olofsson wrote:
Hi,

I did this but i got :

Traceback (most recent call last):
  File /var/www/web2py/gluon/restricted.py, line 192, in restricted
    exec ccode in environment
  File /var/www/web2py/applications/Event/models/db.py, line 18, in
module
    if request.action in read_only_actions:
NameError: name 'read_only_actions' is not defined

type 'exceptions.NameError'(name 'read_only_actions' is not defined)

This error is the reason i asked where it should go.

Maybe some one could shed some light on it ?

Regards,
Nils

On Jul 21, 7:44 pm, Anthony aba...@gmail.com wrote:
 It would go in your model file -- the same place where you would
  normally

 define the db connection.

 Anthony

 On Thursday, July 21, 2011 2:29:45 PM UTC-4, Nils Olofsson wrote:
  Hi Massimo,

  I'm testing amazon's RDS and EC2 , 1 master many slaves.

  I could not find out where exactly I am suppose to be putting this
  code.

  Regards,

  Nils

  On Jul 21, 6:48 pm, Massimo Di Pierro mass...@gmail.com
  wrote:
   You would only use this if you have a replicated database. I.e.
  you
   are running many database servers synced with each other. For
example:
 http://en.wikipedia.org/wiki/Multi-master_replication

   On Jul 21, 12:44 pm, Nils Olofsson nil...@gmail.com wrote:

Hi,

I see this in the Documentation:

if request.action in read_only_actions:
   db =
DAL(shuffle(['mysql://...1','mysql://...2','mysql://...3']))
else:
   db =
DAL(shuffle(['mysql://...3','mysql://...4','mysql://...5']))

I'm not sure where exactly I should be using this ?

And does anyone have some sample code as to how it should be
  used ?

Nils


[web2py] blob attach field issue with 1.97.1

2011-07-22 Thread Richard
My email won't get into my mail box... And I get no answer... So
excuse the duplication if you get it twice...



Hello,

I get errors on update. 2 differents errors are return depending if
the file is attach before update or at the update of the form.

Model definition field
Field('field1','upload',uploadfield='field1_blob'),
Field('field1_blob','blob'),

Error1 (file already attached when record was create) :

Traceback (most recent call last):

  File /version_197-1/web2py/gluon/restricted.py, line 192, in
restricted

exec ccode in environment

  File /version_197-1/web2py/applications/sgddms/controllers/
test.py, line 1338, in module

  File /version_197-1/web2py/gluon/globals.py, line 137, in lambda

self._caller = lambda f: f()

  File /version_197-1/web2py/gluon/tools.py, line 2448, in f

return action(*a, **b)

  File /version_197-1/web2py/applications/sgddms/controllers/
test.py, line 465, in update

if form.accepts(request.vars, session):

  File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts

self.table._db(self.table._id == self.record.id).update(**fields)

  File /version_197-1/web2py/gluon/dal.py, line 5403, in update

fields = self.db[tablename]._listify(update_fields,update=True)

  File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify

raise SyntaxError, 'Field %s does not belong to the table' % name

SyntaxError: Field field1__delete does not belong to the table

Error2 (file is attached when record was verify on a update form an
already created record) :

Traceback (most recent call last):

  File /version_197-1/web2py/gluon/restricted.py, line 192, in
restricted

exec ccode in environment

  File /version_197-1/web2py/applications/sgddms/controllers/
test.py, line 1338, in module

  File /version_197-1/web2py/gluon/globals.py, line 137, in lambda

self._caller = lambda f: f()

  File /version_197-1/web2py/gluon/tools.py, line 2448, in f

return action(*a, **b)

  File /version_197-1/web2py/applications/sgddms/controllers/
test.py, line 465, in update

if form.accepts(request.vars, session):

  File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts

self.table._db(self.table._id == self.record.id).update(**fields)

  File /version_197-1/web2py/gluon/dal.py, line 5403, in update

fields = self.db[tablename]._listify(update_fields,update=True)

  File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify

raise SyntaxError, 'Field %s does not belong to the table' % name

SyntaxError: Field field1_newfilename does not belong to the table


Is there something to change with the model definition for attachement
with 1.97.1 or is it a issue?

Thanks

Richard


[web2py] Re: blogs

2011-07-22 Thread hasan alnator
NO ,  i dont get any errors but can u show me an example of but using
a video in the upload folder
thank you .


[web2py] Re: [Newbie] Best practice to set application wide settings

2011-07-22 Thread David Marko
Look to this web2py utils ...
http://packages.python.org/web2py_utils/index.html

... there is an object for storing/accessing configurations values into 
database. Its very handy ...



[web2py] Re: Web2py Certification Program ?

2011-07-22 Thread Massimo Di Pierro
You are right, I should list the on the web page,
I usually teach the depaul course and I use web2py.

Massimo


On Jul 22, 6:03 am, Miguel Lopes mig.e.lo...@gmail.com wrote:
 There is some private offering, which I think should be listed in web2py.com
 :

 * a program at DePaul 
 University:http://www.cdm.depaul.edu/ipd/Programs/Pages/WebDevelopmentwithPython...
 * a program in Brasil:http://www.cursodepython.com.br/

 And free courses (structured content, besides thewww.web2py.com/book)
 * in Brasil too (go 
 Brasil!):http://web2pybrasil.appspot.com/init/plugin_wiki/page/curso-web2py-000

 The DePaul program page doesn't mention web2py, but the program used to be
 done with web2py, and I guess still is (the word is that  Massimo used to be
 the instructor :-)

 HTH

 2011/7/22 António Ramos ramstei...@gmail.com







  Hello,

  Why not create a web2py certification program?
  It would be good for the programmer and for web2py

  Thank you
  António


[web2py] Re: blob attach field issue with 1.97.1

2011-07-22 Thread Massimo Di Pierro
Can you please try:

Field('field1','upload',uploadfield='field1_blob'),
 
Field('field1_blob','blob',deafult='',writable=False,readable=False),

this should work even if you omit the blob field.

On Jul 22, 8:30 am, Richard ml.richard.vez...@gmail.com wrote:
 My email won't get into my mail box... And I get no answer... So
 excuse the duplication if you get it twice...

 Hello,

 I get errors on update. 2 differents errors are return depending if
 the file is attach before update or at the update of the form.

 Model definition field
     Field('field1','upload',uploadfield='field1_blob'),
     Field('field1_blob','blob'),

 Error1 (file already attached when record was create) :

 Traceback (most recent call last):

   File /version_197-1/web2py/gluon/restricted.py, line 192, in
 restricted

     exec ccode in environment

   File /version_197-1/web2py/applications/sgddms/controllers/
 test.py, line 1338, in module

   File /version_197-1/web2py/gluon/globals.py, line 137, in lambda

     self._caller = lambda f: f()

   File /version_197-1/web2py/gluon/tools.py, line 2448, in f

     return action(*a, **b)

   File /version_197-1/web2py/applications/sgddms/controllers/
 test.py, line 465, in update

     if form.accepts(request.vars, session):

   File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts

     self.table._db(self.table._id == self.record.id).update(**fields)

   File /version_197-1/web2py/gluon/dal.py, line 5403, in update

     fields = self.db[tablename]._listify(update_fields,update=True)

   File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify

     raise SyntaxError, 'Field %s does not belong to the table' % name

 SyntaxError: Field field1__delete does not belong to the table

 Error2 (file is attached when record was verify on a update form an
 already created record) :

 Traceback (most recent call last):

   File /version_197-1/web2py/gluon/restricted.py, line 192, in
 restricted

     exec ccode in environment

   File /version_197-1/web2py/applications/sgddms/controllers/
 test.py, line 1338, in module

   File /version_197-1/web2py/gluon/globals.py, line 137, in lambda

     self._caller = lambda f: f()

   File /version_197-1/web2py/gluon/tools.py, line 2448, in f

     return action(*a, **b)

   File /version_197-1/web2py/applications/sgddms/controllers/
 test.py, line 465, in update

     if form.accepts(request.vars, session):

   File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts

     self.table._db(self.table._id == self.record.id).update(**fields)

   File /version_197-1/web2py/gluon/dal.py, line 5403, in update

     fields = self.db[tablename]._listify(update_fields,update=True)

   File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify

     raise SyntaxError, 'Field %s does not belong to the table' % name

 SyntaxError: Field field1_newfilename does not belong to the table

 Is there something to change with the model definition for attachement
 with 1.97.1 or is it a issue?

 Thanks

 Richard


Re: [web2py] Re: blob attach field issue with 1.97.1

2011-07-22 Thread Richard Vézina
Not working... :-(

Richard

On Fri, Jul 22, 2011 at 9:43 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Can you please try:

 Field('field1','upload',uploadfield='field1_blob'),

 Field('field1_blob','blob',deafult='',writable=False,readable=False),

 this should work even if you omit the blob field.

 On Jul 22, 8:30 am, Richard ml.richard.vez...@gmail.com wrote:
  My email won't get into my mail box... And I get no answer... So
  excuse the duplication if you get it twice...
 
  Hello,
 
  I get errors on update. 2 differents errors are return depending if
  the file is attach before update or at the update of the form.
 
  Model definition field
  Field('field1','upload',uploadfield='field1_blob'),
  Field('field1_blob','blob'),
 
  Error1 (file already attached when record was create) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1__delete does not belong to the table
 
  Error2 (file is attached when record was verify on a update form an
  already created record) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1_newfilename does not belong to the table
 
  Is there something to change with the model definition for attachement
  with 1.97.1 or is it a issue?
 
  Thanks
 
  Richard



[web2py] web2py videos on the internet

2011-07-22 Thread António Ramos
Sorry all post lately but its pertinent ( i think... :)


all videos that i found in the internet are made by massimo(99,99%).

Great videos but i think that with a lot of people using and loving web2py
there shoud be videos from other users experience.


Maximo could stimulate his students to post videos of web2py in the
internet.



It seems that only Massimo cares about videos...

As a brilliant guy that he is he should be woking on more important things.


IMO


Best regards

António


[web2py] Re: jquery mobile switch in view

2011-07-22 Thread Anthony
On Friday, July 22, 2011 4:56:20 AM UTC-4, David Marko wrote: 

 The {{extend }} can use variable as parameter so you can, under ome 
 conditions, compute template name and store it into response object(you can 
 place such code in model)
 e.g.
 response.template=layoutjq.html 

 ... and in a view use the following:
 {{extend response.template}}

 
The only caveat in this case is that you cannot then bytecode compile your 
views (because the value of response.template will not be known at compile 
time).
 
Anthony
 


[web2py] Re: database replication

2011-07-22 Thread Anthony
Have all the tables already been created in the slave databases (web2py may 
be trying to create tables or run migrations)? What happens if you do:
 
db = DAL(shuffle(['connection string']), migrate_enabled=False)
 
 
Anthony

On Friday, July 22, 2011 9:28:40 AM UTC-4, Nils Olofsson wrote:

 Hi, I did something similar, 

 if add in request.function: 
db = DAL(['mysql://Database connection string']) 
 else: 
print Using Slave Database 
db = DAL(shuffle(['database connection string']) 

 That would and uses the slave database (readonly) but, I get this 
 error message. 

 InternalError: (1290, u'The MySQL server is running with the --read- 
 only option so it cannot execute this statement') 

 bar this function add and auth all other functions read data. 
 I looked around at the DAL code and could not find a way to tell the 
 DAL that mysql is read only. 
 any ideas ? 

 Regards, 

 Nils 


 On Jul 22, 1:58 pm, Anthony abas...@gmail.com wrote: 
  You could define 'read_only_actions' anywhere it makes sense, for 
 example: 
  
  read_only_actions = 
 ['list','another_read_action','yet_another_read_action'] 
  if request.function in read_only_actions: 
  db =... ... 
  else 
  db =  
  
  Of course, if that one 'if' statement is the only place you refer to 
  'read_only_actions', then there's no need to define it as a separate 
  variable -- you could just put the list right in the 'if' statement. I 
 think 
  'read_only_actions' was used in the book example just to indicate the 
 idea 
  that you would use the slave databases for actions that don't need to 
 write 
  to the db -- it's just a stand-in for an actual list of such actions. 
  
  Anthony 
  
  
  
  
  
  
  
  On Friday, July 22, 2011 6:50:31 AM UTC-4, Nils Olofsson wrote: 
   Hi, 
   I'm still not sure as to how to go about using this. 
  
   Say, I have a controller with the function list: and a function called 
   write: 
  
   if the function is list then read from slaves, if the function is 
   write, write to master. 
  
   So the correct code should be: 
  
   if request.function in read_only_action: 
   db =... ... 
   else 
   db =  
and this is in the model/db.py file. 
  
   I just don't understand where to define read_only_action or it is 
   used ? 
  
   Regards, 
  
   Nils 
  
   On Jul 21, 9:16 pm, Anthony aba...@gmail.com wrote: 
That's just some (incomplete) example code. You have to define 
'read_only_actions' yourself. In that example, it would be a list 
   functions 
that only need to read (but not write) the database and can therefore 
 be 
given access to one of the slave databases. 
  
Actually, it looks like the code has an error -- it should say 
request.function, not request.action -- I'll make the change. 
  
Anthony 
  
On Thursday, July 21, 2011 3:54:20 PM UTC-4, Nils Olofsson wrote: 
 Hi, 
  
 I did this but i got : 
  
 Traceback (most recent call last): 
   File /var/www/web2py/gluon/restricted.py, line 192, in 
 restricted 
 exec ccode in environment 
   File /var/www/web2py/applications/Event/models/db.py, line 18, 
 in 
 module 
 if request.action in read_only_actions: 
 NameError: name 'read_only_actions' is not defined 
  
 type 'exceptions.NameError'(name 'read_only_actions' is not 
 defined) 
  
 This error is the reason i asked where it should go. 
  
 Maybe some one could shed some light on it ? 
  
 Regards, 
 Nils 
  
 On Jul 21, 7:44 pm, Anthony aba...@gmail.com wrote: 
  It would go in your model file -- the same place where you would 
   normally 
  
  define the db connection. 
  
  Anthony 
  
  On Thursday, July 21, 2011 2:29:45 PM UTC-4, Nils Olofsson wrote: 

   Hi Massimo, 
  
   I'm testing amazon's RDS and EC2 , 1 master many slaves. 
  
   I could not find out where exactly I am suppose to be putting 
 this 
   code. 
  
   Regards, 
  
   Nils 
  
   On Jul 21, 6:48 pm, Massimo Di Pierro mas...@gmail.com 
   wrote: 
You would only use this if you have a replicated database. 
 I.e. 
   you 
are running many database servers synced with each other. For 

 example: 
  http://en.wikipedia.org/wiki/Multi-master_replication 
  
On Jul 21, 12:44 pm, Nils Olofsson nil...@gmail.com wrote: 

  
 Hi, 
  
 I see this in the Documentation: 
  
 if request.action in read_only_actions: 
db = 
 DAL(shuffle(['mysql://...1','mysql://...2','mysql://...3'])) 
 else: 
db = 
 DAL(shuffle(['mysql://...3','mysql://...4','mysql://...5'])) 
  
 I'm not sure where exactly I should be using this ? 
  
 And does anyone have some sample code as to how it should 
 be 
   used ? 
  
 Nils



Re: [web2py] Re: database replication

2011-07-22 Thread nils
Hi Anthony,

That worked, maybe the docs should be updated.

I did try migrate=False, thought they were both the same thing.

Regards,

Nils


On Fri, Jul 22, 2011 at 3:05 PM, Anthony abasta...@gmail.com wrote:
 Have all the tables already been created in the slave databases (web2py may
 be trying to create tables or run migrations)? What happens if you do:

 db = DAL(shuffle(['connection string']), migrate_enabled=False)


 Anthony
 On Friday, July 22, 2011 9:28:40 AM UTC-4, Nils Olofsson wrote:

 Hi, I did something similar,

 if add in request.function:
        db = DAL(['mysql://Database connection string'])
     else:
        print Using Slave Database
        db = DAL(shuffle(['database connection string'])

 That would and uses the slave database (readonly) but, I get this
 error message.

 InternalError: (1290, u'The MySQL server is running with the --read-
 only option so it cannot execute this statement')

 bar this function add and auth all other functions read data.
 I looked around at the DAL code and could not find a way to tell the
 DAL that mysql is read only.
 any ideas ?

 Regards,

 Nils


 On Jul 22, 1:58 pm, Anthony abas...@gmail.com wrote:
  You could define 'read_only_actions' anywhere it makes sense, for
  example:
 
  read_only_actions =
  ['list','another_read_action','yet_another_read_action']
  if request.function in read_only_actions:
      db =... ...
  else
      db = 
 
  Of course, if that one 'if' statement is the only place you refer to
  'read_only_actions', then there's no need to define it as a separate
  variable -- you could just put the list right in the 'if' statement. I
  think
  'read_only_actions' was used in the book example just to indicate the
  idea
  that you would use the slave databases for actions that don't need to
  write
  to the db -- it's just a stand-in for an actual list of such actions.
 
  Anthony
 
 
 
 
 
 
 
  On Friday, July 22, 2011 6:50:31 AM UTC-4, Nils Olofsson wrote:
   Hi,
   I'm still not sure as to how to go about using this.
 
   Say, I have a controller with the function list: and a function called
   write:
 
   if the function is list then read from slaves, if the function is
   write, write to master.
 
   So the correct code should be:
 
   if request.function in read_only_action:
       db =... ...
   else
       db = 
    and this is in the model/db.py file.
 
   I just don't understand where to define read_only_action or it is
   used ?
 
   Regards,
 
   Nils
 
   On Jul 21, 9:16 pm, Anthony aba...@gmail.com wrote:
That's just some (incomplete) example code. You have to define
'read_only_actions' yourself. In that example, it would be a list
   functions
that only need to read (but not write) the database and can
therefore be
given access to one of the slave databases.
 
Actually, it looks like the code has an error -- it should say
request.function, not request.action -- I'll make the change.
 
Anthony
 
On Thursday, July 21, 2011 3:54:20 PM UTC-4, Nils Olofsson wrote:
 Hi,
 
 I did this but i got :
 
 Traceback (most recent call last):
   File /var/www/web2py/gluon/restricted.py, line 192, in
 restricted
     exec ccode in environment
   File /var/www/web2py/applications/Event/models/db.py, line 18,
 in
 module
     if request.action in read_only_actions:
 NameError: name 'read_only_actions' is not defined
 
 type 'exceptions.NameError'(name 'read_only_actions' is not
 defined)
 
 This error is the reason i asked where it should go.
 
 Maybe some one could shed some light on it ?
 
 Regards,
 Nils
 
 On Jul 21, 7:44 pm, Anthony aba...@gmail.com wrote:
  It would go in your model file -- the same place where you would
   normally
 
  define the db connection.
 
  Anthony
 
  On Thursday, July 21, 2011 2:29:45 PM UTC-4, Nils Olofsson
  wrote:
   Hi Massimo,
 
   I'm testing amazon's RDS and EC2 , 1 master many slaves.
 
   I could not find out where exactly I am suppose to be putting
   this
   code.
 
   Regards,
 
   Nils
 
   On Jul 21, 6:48 pm, Massimo Di Pierro mas...@gmail.com
   wrote:
You would only use this if you have a replicated database.
I.e.
   you
are running many database servers synced with each other.
For
 example:
  http://en.wikipedia.org/wiki/Multi-master_replication
 
On Jul 21, 12:44 pm, Nils Olofsson nil...@gmail.com wrote:
 
 Hi,
 
 I see this in the Documentation:
 
 if request.action in read_only_actions:
    db =
 DAL(shuffle(['mysql://...1','mysql://...2','mysql://...3']))
 else:
    db =
 DAL(shuffle(['mysql://...3','mysql://...4','mysql://...5']))
 
 I'm not sure where exactly I should be using this ?
 
 And does anyone have some sample code as to how it should
 be
   used ?
 
 Nils


Re: [web2py] Re: [Newbie] Best practice to set application wide settings

2011-07-22 Thread Bruno Rocha
look at this -
http://martin.tecnodoc.com.ar/default/post/2011/05/13/20_optimize-your-web2py-app-using-the-new-import-method


Re: [web2py] Admin is disabled because insecure channel

2011-07-22 Thread António Ramos
can i use https with rocket?

how to?

thank you
António

2011/7/22 Bruno Rocha rochacbr...@gmail.com

 Use https or change security checks at your own risk in
 applications/admin/models 0.py and access.py.


 2011/7/22 António Ramos ramstei...@gmail.com

 i´m trying to access my server from another machine.

 i started web2py with this command line

 c:\web2py\web2py.exe -i 192.168.1.8


 How to solve it?



 thank you
 António




 --




Re: [web2py] Re: blob attach field issue with 1.97.1

2011-07-22 Thread Richard Vézina
I think that web2py determine that the field name has change :

4674.
4675.
4676.
4677.
4678.
4679.

4680.
4681.
4682.
4683.

new_fields = []
new_fields_names = []
for name in fields:
if not name in self.fields:
if name != 'id':
raise SyntaxError, 'Field %s does not belong to
the table' % name

else:
new_fields.append((self[name],fields[name]))
new_fields_names.append(name)
for ofield in self:

VariablesbuiltinSyntaxErrortype 'exceptions.SyntaxError'name
'field1_newfilename'


field1_blob become field1_newfilename...

There is a problem in the code somewhere.

Richard


On Fri, Jul 22, 2011 at 9:55 AM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Not working... :-(

 Richard


 On Fri, Jul 22, 2011 at 9:43 AM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 Can you please try:

 Field('field1','upload',uploadfield='field1_blob'),

 Field('field1_blob','blob',deafult='',writable=False,readable=False),

 this should work even if you omit the blob field.

 On Jul 22, 8:30 am, Richard ml.richard.vez...@gmail.com wrote:
  My email won't get into my mail box... And I get no answer... So
  excuse the duplication if you get it twice...
 
  Hello,
 
  I get errors on update. 2 differents errors are return depending if
  the file is attach before update or at the update of the form.
 
  Model definition field
  Field('field1','upload',uploadfield='field1_blob'),
  Field('field1_blob','blob'),
 
  Error1 (file already attached when record was create) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1__delete does not belong to the table
 
  Error2 (file is attached when record was verify on a update form an
  already created record) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1_newfilename does not belong to the table
 
  Is there something to change with the model definition for attachement
  with 1.97.1 or is it a issue?
 
  Thanks
 
  Richard





Re: [web2py] web2py videos on the internet

2011-07-22 Thread Bruno Rocha
I have some (in portuguese)

web2py + Ipython ( IDE for what?)
http://vimeo.com/26387038

Comet
http://vimeo.com/18399381

PowerTable
http://vimeo.com/18447603

Uploadify
http://vimeo.com/20107460

I am also recording new videos(which will be subtitled)

There are more videos from brazilian people

This is the web2oy channel on VIMEO - http://vimeo.com/channels/139244 the
same content as listed in http://web2py.com/examples/default/videos



2011/7/22 António Ramos ramstei...@gmail.com

 Sorry all post lately but its pertinent ( i think... :)


 all videos that i found in the internet are made by massimo(99,99%).

 Great videos but i think that with a lot of people using and loving web2py
 there shoud be videos from other users experience.


 Maximo could stimulate his students to post videos of web2py in the
 internet.



 It seems that only Massimo cares about videos...

 As a brilliant guy that he is he should be woking on more important things.


 IMO


 Best regards

 António




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] Re: database replication

2011-07-22 Thread Anthony
On Friday, July 22, 2011 10:12:01 AM UTC-4, nils wrote: 

 Hi Anthony, 

 That worked, maybe the docs should be updated.

Indeed.

 I did try migrate=False, thought they were both the same thing.

migrate=False (as an argument to DAL) doesn't turn off migrations -- it 
merely determines the default value of migrate for define_table() when it is 
not explicitly specified. So, DAL(..., migrate=False) should have the same 
effect as DAL(..., migrate_enabled=False) as long as none of your 
db.define_table() calls explicilty sets their 'migrate' argument. Do you 
have an explicit migrate=True in at least one of your db.define_table() 
calls?
 
Anthony
 



[web2py] heroku, web2py and gunicorn

2011-07-22 Thread Massimo Di Pierro
Hello everybody,

heroku will be supporting web2py. They run gunicorn. web2py runs with
gunicorn but I have never tried it.

Any volunteer to run some stress tests?

cd web2py
python anyserver -s gunicorn

Massimo


[web2py] Re: Unable to install application kpax

2011-07-22 Thread neilrobau2
Tried again with tick on Overwrite Installed App - it worked!

On Jul 22, 11:39 am, neilrobau2 neilro...@gmail.com wrote:
 VERSION says Version 1.97.1 (2011-06-26 19:25:44). Downloaded as
 Current (for everybody)
 Version 1.97.1 (2011-06-26 19:25:44), Windows version.

 On Jul 22, 3:45 am, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  Did you get admin from stable or trunk? What is the date in your
  web2py/VERSION file?

  On Jul 21, 11:15 am, neilrobau2 neilro...@gmail.com wrote:

   Following the web2py book, chapter 03 Overview, I try to installKPAX
   via the Admin page.
   Admin show version 1.97.1.

   Under upload and install packed application I provide 
   URLhttp://web2py.com/appliances/default/download/app.source.221663266939...
   as in the book - I get Unableto install apllication kpax.

   If I download web2py.app.kpax_cms.w2p, and supply that file in the
   Upload a Package field, I get the same message.

   I can view the source file applications\admin\controllers\default.py
   and see where app_install is called and that error message is
   produced, but grep in the web2py and contained directories for
   app_install does not show me the definition of app_install.

   Any ideas?


[web2py] Re: Unable to install application kpax

2011-07-22 Thread Massimo Di Pierro
fascinating

On Jul 22, 10:36 am, neilrobau2 neilro...@gmail.com wrote:
 Tried again with tick on Overwrite Installed App - it worked!

 On Jul 22, 11:39 am, neilrobau2 neilro...@gmail.com wrote:







  VERSION says Version 1.97.1 (2011-06-26 19:25:44). Downloaded as
  Current (for everybody)
  Version 1.97.1 (2011-06-26 19:25:44), Windows version.

  On Jul 22, 3:45 am, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   Did you get admin from stable or trunk? What is the date in your
   web2py/VERSION file?

   On Jul 21, 11:15 am, neilrobau2 neilro...@gmail.com wrote:

Following the web2py book, chapter 03 Overview, I try to installKPAX
via the Admin page.
Admin show version 1.97.1.

Under upload and install packed application I provide 
URLhttp://web2py.com/appliances/default/download/app.source.221663266939...
as in the book - I get Unableto install apllication kpax.

If I download web2py.app.kpax_cms.w2p, and supply that file in the
Upload a Package field, I get the same message.

I can view the source file applications\admin\controllers\default.py
and see where app_install is called and that error message is
produced, but grep in the web2py and contained directories for
app_install does not show me the definition of app_install.

Any ideas?


[web2py] autofilling (redefining?) a Field value

2011-07-22 Thread mart
Hi,

I would like to have a table field 'autofill' a value based on another
field's choice. I would like to have a link displayed depending on the
user's server name choice. something like this (but obviously this is
wrong ;) )

this is the table definition (the last validation line is the issue):

db.define_table('build',
Field('title'),Field('description',length=256),
 
Field('category',requires=IS_IN_DB(db,db.category.name)),
Field('date','date',default=datetime.datetime.now()),
 
Field('URL','text'),Field('buildServer',requires=IS_IN_DB(db,db.buildserver.name)))

db.category.name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'category.name')]
db.build.title.requires=[IS_NOT_EMPTY()]
db.build.description.requires=IS_NOT_EMPTY()
db.build.category.requires=IS_IN_DB(db,'category.id','category.name')
db.build.date.requires=IS_DATE()
db.build.URL='http://{0}/blueLite/default/
index.html'.format(db.build.buildServer)



if the user fills the form, and chooses a server from the
'buildServer' field, I would like the 'URL' field to autofill with the
user's server choice as variable. So something like the last
validation line above ( db.build.URL='http://{0}/blueLite/default/
index.html'.format(db.build.buildServer) )

Any ideas how this can work?

thanks,
Mart :)


Re: [web2py] heroku, web2py and gunicorn

2011-07-22 Thread Furqan Rauf
I could do it but I am a newbie, no nothing about the deployment or stress
testing

On Fri, Jul 22, 2011 at 10:06 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Hello everybody,

 heroku will be supporting web2py. They run gunicorn. web2py runs with
 gunicorn but I have never tried it.

 Any volunteer to run some stress tests?

 cd web2py
 python anyserver -s gunicorn

 Massimo




-- 
*-Furqan Rauf*
*Do you love your creator? Love your fellow-beings first. -Prophet Muhammad
*
*http://www.amway.com/furqanrauf*


Re: [web2py] Re: blob attach field issue with 1.97.1

2011-07-22 Thread Richard Vézina
Can't reproduce the problem in a simple app... Look like it come from my
update function code... What should I like for?

Thanks

Richard

On Fri, Jul 22, 2011 at 10:21 AM, Richard Vézina 
ml.richard.vez...@gmail.com wrote:

 I think that web2py determine that the field name has change :

 4674.
 4675.
 4676.
 4677.
 4678.

 4679.

 4680.
 4681.
 4682.
 4683.

 new_fields = []

 new_fields_names = []

 for name in fields:

 if not name in self.fields:

 if name != 'id':


 raise SyntaxError, 'Field %s does not belong to the 
 table' % name

 else:

 new_fields.append((self[name],fields[name]))

 new_fields_names.append(name)

 for ofield in self:

  Variables  builtinSyntaxError type 'exceptions.SyntaxError' 
 name'field1_newfilename'


 field1_blob become field1_newfilename...

 There is a problem in the code somewhere.

 Richard


 On Fri, Jul 22, 2011 at 9:55 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Not working... :-(

 Richard


 On Fri, Jul 22, 2011 at 9:43 AM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 Can you please try:

 Field('field1','upload',uploadfield='field1_blob'),

 Field('field1_blob','blob',deafult='',writable=False,readable=False),

 this should work even if you omit the blob field.

 On Jul 22, 8:30 am, Richard ml.richard.vez...@gmail.com wrote:
  My email won't get into my mail box... And I get no answer... So
  excuse the duplication if you get it twice...
 
  Hello,
 
  I get errors on update. 2 differents errors are return depending if
  the file is attach before update or at the update of the form.
 
  Model definition field
  Field('field1','upload',uploadfield='field1_blob'),
  Field('field1_blob','blob'),
 
  Error1 (file already attached when record was create) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1__delete does not belong to the table
 
  Error2 (file is attached when record was verify on a update form an
  already created record) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1_newfilename does not belong to the table
 
  Is there something to change with the model definition for attachement
  with 1.97.1 or is it a issue?
 
  Thanks
 
  Richard






[web2py] Re: Can't get linkto working in SQLFORM

2011-07-22 Thread DenesL

Yes, I can reproduce it running web2py 1.97.1 from source on Windows.

 link=URL('list_records')
 print link
/test/default/list_records
 form = SQLFORM(db.person,1,linkto=link)
 print form.element('#dog__owner__row')
tr id=dog__owner__rowtd class=w2p_fl/tdtd class=w2p_fwa
class=reference href=/test/default/list_records/dog?
query=list_records.dog.owner%3D%3D1dog.owner/a/tdtd
class=w2p_fc/td/tr

sqlhtml.py line 845 does not seem right on getting db:
db = linkto.split('/')[-1]

but is seems strange that nobody has complained about it before since
that has been in place for a few releases back.

Denes.


On Jul 21, 1:18 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I cannot reproduce this. Can anybody else?

 On Jul 18, 8:13 pm, tcab abu...@gmail.com wrote:







  Ok - added issue ashttp://code.google.com/p/web2py/issues/detail?id=340

  On Jul 15, 9:45 am, Anthony abasta...@gmail.com wrote:

   Please submit an issue on Google 
   Code:http://code.google.com/p/web2py/issues/list

   On Friday, July 15, 2011 1:33:22 AM UTC-4, tcab wrote:
I get this too - a spurious list_records. prepended to the query.
Latest web2py 1.97.1

-Andy

On Jul 12, 10:08 pm, jc j-c...@lineone.net wrote:
 Hi,
 Trying to uselinkto, so following example in web2py book
   http://www.web2py.com/book/default/chapter/07#Links-to-Referencing-Re...
first,
 to try to understand.

 I have copied the example with person and dog tables, in particular in
def
 display_form(): I have

 link = URL('list_records')
 form = SQLFORM(db.person, record, deletable=True,
                   upload=url,linkto=link, labels = {'dog.owner':This
 person's dogs})

 as described in the book.

 The books says the link generated will be
 /test/default/list_records/dog?query=dog.owner%3D5 but in fact the 
 link

 which appears when I visit /test/default/display_form/1 is
  /test/default/list_records/dog?query=list_records.dog.owner%3D%3D1,
i.e.
 there is a spurious list.records and a spurious %3D. Not surprisingly 
 the

 link doesn't work. Can anybody tell me what I am doing wrong?

 Thanks.


[web2py] Re: Admin is disabled because insecure channel

2011-07-22 Thread Massimo Di Pierro
 python web2py.py  -h
...
  -p PORT, --port=PORT  port of server (8000)
...
  -c SSL_CERTIFICATE, --ssl_certificate=SSL_CERTIFICATE
file that contains ssl certificate
  -k SSL_PRIVATE_KEY, --ssl_private_key=SSL_PRIVATE_KEY
file that contains ssl private key
...

these are all the options you need. You must run two copies one on
port 80 and one on port 443.

On Jul 22, 9:20 am, António Ramos ramstei...@gmail.com wrote:
 can i use https with rocket?

 how to?

 thank you
 António

 2011/7/22 Bruno Rocha rochacbr...@gmail.com







  Use https or change security checks at your own risk in
  applications/admin/models 0.py and access.py.

  2011/7/22 António Ramos ramstei...@gmail.com

  i´m trying to access my server from another machine.

  i started web2py with this command line

  c:\web2py\web2py.exe -i 192.168.1.8

  How to solve it?

  thank you
  António

  --


Re: [web2py] Re: database replication

2011-07-22 Thread nils
Hi Anthony,

yes, migrate is set for fields in the  aut table.

Also another note, shuffle did not work for me I have to, from random
import sample.
then change
DAL(sample(['mysql connection string','mysql connection
string'],1),migrate_enabled=False)

Regards,

Nils

On Fri, Jul 22, 2011 at 4:02 PM, Anthony abasta...@gmail.com wrote:
 On Friday, July 22, 2011 10:12:01 AM UTC-4, nils wrote:

 Hi Anthony,

 That worked, maybe the docs should be updated.

 Indeed.

 I did try migrate=False, thought they were both the same thing.

 migrate=False (as an argument to DAL) doesn't turn off migrations -- it
 merely determines the default value of migrate for define_table() when it is
 not explicitly specified. So, DAL(..., migrate=False) should have the same
 effect as DAL(..., migrate_enabled=False) as long as none of your
 db.define_table() calls explicilty sets their 'migrate' argument. Do you
 have an explicit migrate=True in at least one of your db.define_table()
 calls?

 Anthony



Re: [web2py] Re: Admin is disabled because insecure channel

2011-07-22 Thread António Ramos
2 copies one with ssl certificate and another without ssl?

why?


António

2011/7/22 Massimo Di Pierro massimo.dipie...@gmail.com

  python web2py.py  -h
 ...
  -p PORT, --port=PORT  port of server (8000)
 ...
  -c SSL_CERTIFICATE, --ssl_certificate=SSL_CERTIFICATE
file that contains ssl certificate
  -k SSL_PRIVATE_KEY, --ssl_private_key=SSL_PRIVATE_KEY
file that contains ssl private key
 ...

 these are all the options you need. You must run two copies one on
 port 80 and one on port 443.

 On Jul 22, 9:20 am, António Ramos ramstei...@gmail.com wrote:
  can i use https with rocket?
 
  how to?
 
  thank you
  António
 
  2011/7/22 Bruno Rocha rochacbr...@gmail.com
 
 
 
 
 
 
 
   Use https or change security checks at your own risk in
   applications/admin/models 0.py and access.py.
 
   2011/7/22 António Ramos ramstei...@gmail.com
 
   i´m trying to access my server from another machine.
 
   i started web2py with this command line
 
   c:\web2py\web2py.exe -i 192.168.1.8
 
   How to solve it?
 
   thank you
   António
 
   --



[web2py] Re: Tiny example on uwsgidecorators+web2py

2011-07-22 Thread Tiago Moutinho
I using 0.9.8.1.
How can i update to 0.9.8.2

thks in advance

On Jul 22, 10:15 am, Roberto De Ioris robe...@unbit.it wrote:
 Il giorno 22/lug/2011, alle ore 11:09, Tiago Moutinho ha scritto:

  thks Roberto,

  tiago@tiago:~$ cd /opt/web2py/
  tiago@tiago:/opt/web2py$ mkdir myspool
  tiago@tiago:/opt/web2py$ uwsgi --socket :3031 --spooler myspool --
  master --processes 4 --import mytasks --module web2py.wsgihandler
  uwsgi: unrecognized option '--import'

 Are you using the latest stable release ?

 --import was added in 0.9.8.2 (there are other ways to implement this in 
 0.9.8.1 but --import
 is so handy that the upgrade is worthy :) )

 --
 Roberto De Iorishttp://unbit.it


Re: [web2py] Re: Tiny example on uwsgidecorators+web2py

2011-07-22 Thread Roberto De Ioris

 I using 0.9.8.1.
 How can i update to 0.9.8.2

 thks in advance


pip install uwsgi
(or pip install -U uwsgi)


Or download the sources from the official site and recompile them.

BTW we are getting a bit Off-topic i suppose we can move the discussion to
the uWSGI list (or the irc channel) and come back here when you have a
working setup :)



 On Jul 22, 10:15 am, Roberto De Ioris robe...@unbit.it wrote:
 Il giorno 22/lug/2011, alle ore 11:09, Tiago Moutinho ha scritto:

  thks Roberto,

  tiago@tiago:~$ cd /opt/web2py/
  tiago@tiago:/opt/web2py$ mkdir myspool
  tiago@tiago:/opt/web2py$ uwsgi --socket :3031 --spooler myspool --
  master --processes 4 --import mytasks --module web2py.wsgihandler
  uwsgi: unrecognized option '--import'

 Are you using the latest stable release ?

 --import was added in 0.9.8.2 (there are other ways to implement this in
 0.9.8.1 but --import
 is so handy that the upgrade is worthy :) )

 --
 Roberto De Iorishttp://unbit.it



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


[web2py] Re: virtual fields multiple execution

2011-07-22 Thread howesc
massimo accepted my patch, so i guess that validates it.

thanks!!!

christian


Re: [web2py] Re: database replication

2011-07-22 Thread Anthony
On Friday, July 22, 2011 12:28:24 PM UTC-4, nils wrote: 

 Hi Anthony, 

 yes, migrate is set for fields in the  aut table. 

 Also another note, shuffle did not work for me I have to, from random
 import sample.
 then change
 DAL(sample(['mysql connection string','mysql connection
 string'],1),migrate_enabled=False)

Yes, good point, shuffle returns None (after mutating the list in place), so 
the example will not work properly. Note, if you sample only 1 slave db, 
that's fine, but you're better off returning a permutation of the whole list 
-- then, if DAL can't connect to one of the db's, it will try the next one 
in the list instead of failing.
 
Anthony
 


[web2py] Re: virtual fields multiple execution

2011-07-22 Thread Massimo Di Pierro
Yes your patch looks right and a major speedup. The pre-patch code
should be considered buggy because it was evaluating the virtual
fields more time necessary.

On Jul 22, 11:49 am, howesc how...@umich.edu wrote:
 massimo accepted my patch, so i guess that validates it.

 thanks!!!

 christian


Re: [web2py] Re: database replication

2011-07-22 Thread Anthony
Just changed the book example to use random.sample.
 
Anthony

On Friday, July 22, 2011 12:55:46 PM UTC-4, Anthony wrote:

 On Friday, July 22, 2011 12:28:24 PM UTC-4, nils wrote: 

 Hi Anthony, 

 yes, migrate is set for fields in the  aut table. 

 Also another note, shuffle did not work for me I have to, from random
 import sample.
 then change
 DAL(sample(['mysql connection string','mysql connection
 string'],1),migrate_enabled=False)

 Yes, good point, shuffle returns None (after mutating the list in place), 
 so the example will not work properly. Note, if you sample only 1 slave db, 
 that's fine, but you're better off returning a permutation of the whole list 
 -- then, if DAL can't connect to one of the db's, it will try the next one 
 in the list instead of failing.
  
 Anthony
  



[web2py] Re: No CallBack (Onaccept) When using facebook or Twitter Connect for loging.

2011-07-22 Thread howesc
this is a kinda nasty little bugger.  the facebook published way is to call 
FB.logout() (assuming you are using the javascript FB API) after you call 
the web2py logout function:

var SM = {
  'facebookLogout' : function () {
FB.logout(function(response) {
  $(location).attr('href', '/auth/logout');
});
return false;
  },
  'logout_user' : function () {
var my_id = fbs_+ fb_id.toString();
if (document.cookie.indexOf(my_id) != -1){ //if Facebook Cookie Exists, 
then we have a facebook user and call FB.logout
  SM.facebookLogout();
}
else{
  $(location).attr('href', '/auth/logout');
}
return false;
  },
};


now that also logs you out of facebook.

my coworker working on starmakerstudios.com tried to find and delete the FB 
cookie, but it did not work consistently.  apparently trying to ask the 
browser to delete cookies is like taking a cat for a walk.

the trouble is that the facebook javascript API assumes that once you login 
to the site that you want your login preserved forever.

good luck!

cfh

Sorry to bother you.
I have a quick question. I'm close to finish the facebook integration
with my application but I still have few issue.
My Logout doesn't seems to work properly. Right now when I logout here
is what I do in the function logout():
def logout():
next = URL(r=request,c='default', f='index')
del session.redirect_uri
del session.token
del session._Session__hash
auth.logout(next)
So once doing that the application successfully redirect me to the
logout page... Next when I tried to log back in the application login
me IN WITHOUT going through Facebook login page (It Authenticate in
the back-end). I guess this is because of the FaceBook Cookies in the
browser and by login out from my application I can't delete that
cookies. (This happen even WITHOUT any Facebook session active in
another tab of the browser...).
Do you know how my log out can clear out the cookies so that next time
I log back in the Facebook connect page appear ?
Thanks,
Yannick P.



Re: [web2py] Re: Admin is disabled because insecure channel

2011-07-22 Thread Ross Peoples
The web2py server can only run on one port at a time and you cannot run a 
secure and a non-secure site from the same port. So you have to run two 
instances of the web2py server, one using ssl certs, and the other without.

[web2py] viewing a uploaded video

2011-07-22 Thread hasan alnator
Hello ,

am trying to view an uploaded video using the mediaplayer in the
plugin wiki but i dont know why its not playing anything out of the
static folder  ::

{{=plugin_wiki.widget('mediaplayer',src='/SQLFORMS_AND_UPLOAD/uploads/
person.image.
94758e04f2f20187.4a7175657279202d20416a6178205475746f7269616c2e6d7034.mp4')}}

its not working , it links to an uploaded video  ...

can you help me guys

thank you all


[web2py] Re: jquery mobile switch in view

2011-07-22 Thread Ross Peoples
I have been pondering this for quite a while, and the only way I can think 
of doing this, while retaining the bytecompile option is to wrap the 
layout.html file in a if/then statement, and checking for mobile browsers in 
a model somewhere.

So your model would have a variable called is_mobile that determines if the 
current request is from a mobile browser. Then your model would contain 
something like this:

if is_mobile and request.extension == 'html':
request.extension = 'mobile'

Then your layout.html would contain something like this:

{{if is_mobile:}}
!-- Your layout for mobile devices (such as the contents of 
plugin_jqmobile/layout.html) goes here --
{{else:}}
!-- The rest of the original layout.html file (or your custom layout) 
goes here --
{{pass}}

Then you can make views regular and mobile views. Regular views having the 
.html extension, and mobile views having a .mobile extension.


Re: [web2py] Re: blob attach field issue with 1.97.1

2011-07-22 Thread Richard Vézina
Look for...

Richard

On Fri, Jul 22, 2011 at 12:03 PM, Richard Vézina 
ml.richard.vez...@gmail.com wrote:

 Can't reproduce the problem in a simple app... Look like it come from my
 update function code... What should I like for?

 Thanks

 Richard


 On Fri, Jul 22, 2011 at 10:21 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 I think that web2py determine that the field name has change :




 4674.
 4675.
 4676.
 4677.
 4678.


 4679.

 4680.
 4681.
 4682.
 4683.

 new_fields = []


 new_fields_names = []


 for name in fields:


 if not name in self.fields:


 if name != 'id':



 raise SyntaxError, 'Field %s does not belong to the 
 table' % name


 else:


 new_fields.append((self[name],fields[name]))


 new_fields_names.append(name)


 for ofield in self:

  Variables  builtinSyntaxError type 'exceptions.SyntaxError' 
 name'field1_newfilename'


 field1_blob become field1_newfilename...

 There is a problem in the code somewhere.

 Richard


 On Fri, Jul 22, 2011 at 9:55 AM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Not working... :-(

 Richard


 On Fri, Jul 22, 2011 at 9:43 AM, Massimo Di Pierro 
 massimo.dipie...@gmail.com wrote:

 Can you please try:

 Field('field1','upload',uploadfield='field1_blob'),

 Field('field1_blob','blob',deafult='',writable=False,readable=False),

 this should work even if you omit the blob field.

 On Jul 22, 8:30 am, Richard ml.richard.vez...@gmail.com wrote:
  My email won't get into my mail box... And I get no answer... So
  excuse the duplication if you get it twice...
 
  Hello,
 
  I get errors on update. 2 differents errors are return depending if
  the file is attach before update or at the update of the form.
 
  Model definition field
  Field('field1','upload',uploadfield='field1_blob'),
  Field('field1_blob','blob'),
 
  Error1 (file already attached when record was create) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1__delete does not belong to the table
 
  Error2 (file is attached when record was verify on a update form an
  already created record) :
 
  Traceback (most recent call last):
 
File /version_197-1/web2py/gluon/restricted.py, line 192, in
  restricted
 
  exec ccode in environment
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 1338, in module
 
File /version_197-1/web2py/gluon/globals.py, line 137, in lambda
 
  self._caller = lambda f: f()
 
File /version_197-1/web2py/gluon/tools.py, line 2448, in f
 
  return action(*a, **b)
 
File /version_197-1/web2py/applications/sgddms/controllers/
  test.py, line 465, in update
 
  if form.accepts(request.vars, session):
 
File /version_197-1/web2py/gluon/sqlhtml.py, line 1203, in accepts
 
  self.table._db(self.table._id == self.record.id).update(**fields)
 
File /version_197-1/web2py/gluon/dal.py, line 5403, in update
 
  fields = self.db[tablename]._listify(update_fields,update=True)
 
File /version_197-1/web2py/gluon/dal.py, line 4679, in _listify
 
  raise SyntaxError, 'Field %s does not belong to the table' % name
 
  SyntaxError: Field field1_newfilename does not belong to the table
 
  Is there something to change with the model definition for attachement
  with 1.97.1 or is it a issue?
 
  Thanks
 
  Richard







[web2py] Re: Tiny example on uwsgidecorators+web2py

2011-07-22 Thread Tiago Moutinho
I'M sorry Roberto for this boring question, but it gives an error in
web2py when i try to run the controller, and i don't know ao to solve
this.

Exception: you have to enable the uWSGI spooler to use the @spool
decorator

Thks in advance

On Jul 22, 5:39 pm, Roberto De Ioris robe...@unbit.it wrote:
  I using 0.9.8.1.
  How can i update to 0.9.8.2

  thks in advance

 pip install uwsgi
 (or pip install -U uwsgi)

 Or download the sources from the official site and recompile them.

 BTW we are getting a bit Off-topic i suppose we can move the discussion to
 the uWSGI list (or the irc channel) and come back here when you have a
 working setup :)











  On Jul 22, 10:15 am, Roberto De Ioris robe...@unbit.it wrote:
  Il giorno 22/lug/2011, alle ore 11:09, Tiago Moutinho ha scritto:

   thks Roberto,

   tiago@tiago:~$ cd /opt/web2py/
   tiago@tiago:/opt/web2py$ mkdir myspool
   tiago@tiago:/opt/web2py$ uwsgi --socket :3031 --spooler myspool --
   master --processes 4 --import mytasks --module web2py.wsgihandler
   uwsgi: unrecognized option '--import'

  Are you using the latest stable release ?

  --import was added in 0.9.8.2 (there are other ways to implement this in
  0.9.8.1 but --import
  is so handy that the upgrade is worthy :) )

  --
  Roberto De Iorishttp://unbit.it

 --
 Roberto De Iorishttp://unbit.it


[web2py] Re: Tiny example on uwsgidecorators+web2py

2011-07-22 Thread Tiago Moutinho
How can i enable the spooler?

I have pass target='spooler' to the decorator args but it gives the
same error.


On Jul 22, 7:44 pm, Tiago Moutinho tiago...@gmail.com wrote:
 I'M sorry Roberto for this boring question, but it gives an error in
 web2py when i try to run the controller, and i don't know ao to solve
 this.

 Exception: you have to enable the uWSGI spooler to use the @spool
 decorator

 Thks in advance

 On Jul 22, 5:39 pm, Roberto De Ioris robe...@unbit.it wrote:







   I using 0.9.8.1.
   How can i update to 0.9.8.2

   thks in advance

  pip install uwsgi
  (or pip install -U uwsgi)

  Or download the sources from the official site and recompile them.

  BTW we are getting a bit Off-topic i suppose we can move the discussion to
  the uWSGI list (or the irc channel) and come back here when you have a
  working setup :)

   On Jul 22, 10:15 am, Roberto De Ioris robe...@unbit.it wrote:
   Il giorno 22/lug/2011, alle ore 11:09, Tiago Moutinho ha scritto:

thks Roberto,

tiago@tiago:~$ cd /opt/web2py/
tiago@tiago:/opt/web2py$ mkdir myspool
tiago@tiago:/opt/web2py$ uwsgi --socket :3031 --spooler myspool --
master --processes 4 --import mytasks --module web2py.wsgihandler
uwsgi: unrecognized option '--import'

   Are you using the latest stable release ?

   --import was added in 0.9.8.2 (there are other ways to implement this in
   0.9.8.1 but --import
   is so handy that the upgrade is worthy :) )

   --
   Roberto De Iorishttp://unbit.it

  --
  Roberto De Iorishttp://unbit.it


[web2py] DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Ross Peoples
As mobile devices get more popular, it is important for many sites and apps 
to provide both a regular (desktop) site and a mobile site. It is currently 
difficult to accomplish this with web2py. Plugin jqmobile is great for 
mobile devices, but doesn't really work for regular web browsers.

I am determined to find a way to allow web2py to run a desktop and a mobile 
version of an app without giving up the ability to byte compile apps. I 
think I found a solution, but it will require a couple of patches to the 
web2py core first. This first patch will add is_mobile to the request 
object.

So in your views or controllers, you can just test for a mobile view:

if request.is_mobile:
response.view = 'default/index.mobile'

Of course, you would not be required to do this if my solution for native 
web2py support works out, as checking for desktop/mobile views would be done 
automatically.

My end goal is to provide an out-of-the-box solution for web2py that will 
allow you to make your own mobile layout and mobile views without breaking 
backwards compatibility, while still allowing applications to be byte 
compiled. My plan is to provide a mobile layout (like plugin_jqmobile's), 
along with the existing desktop layout. Then, mobile views would have the 
.mobile extension. If the .mobile view isn't available it would fallback to 
the standard .html view that is used for desktops.

I am posting this to get the community's opinion on including this 
functionality into web2py before I devote my time to actually developing the 
solution. Does anyone see any problems with my logic so far, or about the 
way the mobile sites are implemented alongside the regular sites?


[web2py] GAE users - SDK upgrade breaks your test database

2011-07-22 Thread howesc
Hi all,

if you are using GAE and upgrade to yesterday's release of the SDK you will 
find that all your data has disappeared!  where oh where did it go?  well, 
someone at google had the bright idea to change your appname when running in 
the development server to dev~appname.  this means that the datastore 
can't find your data cause it was stored under the straight app name.

if you can re-import your test data it seems to work just fine.

if you are lucky enough to be using sqlite you can connect to the db and 
rename some tables to get it to work:

sqlite3 local_appname_dev_sqlite.datastore
sqlite .tables
Apps  
IdSeq 
Namespaces
appname!!Entities
appname!!EntitiesByProperty  
appname!namespace!Entities  
appname!namespace!EntitiesByProperty
sqlite alter table `appname!!Entities` rename to `dev~appname!!Entities`;
sqlite alter table `appname!!EntitiesByProperty` rename to 
`dev~appname!!EntitiesByProperty`;
sqlite alter table `appname!namespace!Entities` rename to 
`dev~appname!namespace!Entities`;
sqlite alter table `appname!namespace!EntitiesByProperty` rename to 
`dev~appname!namespace!EntitiesByProperty`;


where you substitute 'appname' for your application's name, and 'namespace' 
for your data namespace.

good luck!

christian


[web2py] Re: Just started web development

2011-07-22 Thread Ross Peoples
Welcome to web2py. Let us know if you need help. Just be sure you check the 
book first before asking questions, as it is a really good resource and 
answers the most common questions.

[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Ross Peoples
If this functionality is desired, then consider the mentioned patch to be 
the first of many to come:

http://code.google.com/p/web2py/issues/detail?id=346


[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Anthony
+1

On Friday, July 22, 2011 3:14:02 PM UTC-4, Ross Peoples wrote:

 As mobile devices get more popular, it is important for many sites and apps 
 to provide both a regular (desktop) site and a mobile site. It is currently 
 difficult to accomplish this with web2py. Plugin jqmobile is great for 
 mobile devices, but doesn't really work for regular web browsers.

 I am determined to find a way to allow web2py to run a desktop and a mobile 
 version of an app without giving up the ability to byte compile apps. I 
 think I found a solution, but it will require a couple of patches to the 
 web2py core first. This first patch will add is_mobile to the request 
 object. 

 So in your views or controllers, you can just test for a mobile view:

 if request.is_mobile:
 response.view = 'default/index.mobile'

 Of course, you would not be required to do this if my solution for native 
 web2py support works out, as checking for desktop/mobile views would be done 
 automatically.

 My end goal is to provide an out-of-the-box solution for web2py that will 
 allow you to make your own mobile layout and mobile views without breaking 
 backwards compatibility, while still allowing applications to be byte 
 compiled. My plan is to provide a mobile layout (like plugin_jqmobile's), 
 along with the existing desktop layout. Then, mobile views would have the 
 .mobile extension. If the .mobile view isn't available it would fallback to 
 the standard .html view that is used for desktops.

 I am posting this to get the community's opinion on including this 
 functionality into web2py before I devote my time to actually developing the 
 solution. Does anyone see any problems with my logic so far, or about the 
 way the mobile sites are implemented alongside the regular sites?



[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Chris May
Hey Ross, thanks for starting this discussion. And what a timely
discussion, considering today's Smashing Magazine article is a roundup
of Responsive Design (RD) patterns. (www.smashingmagazine.com)

(For those unfamiliar with RD, also check out A List Apart for a great
intro: http://www.alistapart.com/articles/responsive-web-design/)

I agree that it would be valuable to make it easier to address mobile
and desktop environments, and I've been wondering how to work with
web2py on this front as well. I notice that in the bottom of base.css
for web2py, there is space for RD, which is a good starting point to
have one bass CSS file that can work for desktop and mobile
environments. I feel this can work well for pages that would serve the
same content to desktop and mobile browsers. But I don't know how
common that is.

One major issue I find is getting a reliable way to detect a mobile
environment.

I have worked with some people who are attempting to keep a database
of browser agents to determine it that way. I would think it's a
nightmare to keep that list up to date.

I know the folks at http://yiibu.com/ have come up with a possible
solution, following the mobile first pattern. But I haven't been
able to dive into their code yet.

Thus far in sites I've recently developed, I've limited my mobile
environment detection to finding out the browser width and using CSS
to change the layouts and images.

How do you think we can reliably detect a mobile environment?



Re: [web2py] Re: Just started web development

2011-07-22 Thread Furqan Rauf
I do have questions but right now I am going through lot of work related
work and other businesses so once I get back to development of my app I will
make sure to research before bugging you guys, Also I want to help develop
and enrich the web2py framework so feel free to throw some task at me, I am
a newbie programmer but willing to learn.



On Fri, Jul 22, 2011 at 2:29 PM, Ross Peoples ross.peop...@gmail.comwrote:

 Welcome to web2py. Let us know if you need help. Just be sure you check the
 book first before asking questions, as it is a really good resource and
 answers the most common questions.




-- 
*-Furqan Rauf*
*Do you love your creator? Love your fellow-beings first. -Prophet Muhammad
*
*http://www.amway.com/furqanrauf*


[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread howesc
it's been years since i last was doing device detection, but i used the 
WURFL: http://wurfl.sourceforge.net/




[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Ross Peoples
I have already submitted a patch to address device detection. It's very simple 
and uses the user agent string. It may not be the most elegant way to do 
detection, but it works and it's really fast. I tested the detection using an 
iPhone and an iPad, but I don't have any other devices to test with. 
Regardless, it should pick up 99% of mobile devices, if not more.

I've also figured out a way to switch to the mobile layout without messing up 
byte compile. So far the important proof of concept pieces are falling into 
place perfectly.


Re: [web2py] Re: Just started web development

2011-07-22 Thread cjrh
On Friday, 22 July 2011 23:02:28 UTC+2, Furqan wrote:

 Also I want to help develop and enrich the web2py framework so feel free to 
 throw some task at me, I am a newbie programmer but willing to learn.


Excellent.  This places you in a good position to evaluate whether the 
documentation (web2py.com/book) is adequate for persons new to web2py. 
 While learning from the book, it would be great if you could point out here 
in this group any sections in the book that are not clear, or misleading, or 
even outright incorrect.  If you follow the book's examples, and your 
attempt doesn't work because of some subtlety that the book glosses over, or 
fails to emphasize appropriately, then please do mention those too.  I am 
particularly curious as to whether the book is suitable to newcomers.  It 
really becomes impossible to tell after one has worked with the framework 
for a while.


[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread pbreit
This came out recently:
http://www.getskeleton.com

It seems to me pretty difficult to make one web app work well on both large 
and small screens.


[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Ross Peoples
It is difficult to make the same views and everything work on small and large 
screens. The solution I am proposing is a separate layout for mobile devices 
based on plugin_jqmobile. Views would use .html versions of the views unless 
overridden by a .mobile view. This way, simple views don't need to be 
duplicated, and mobile-specific views are easy to include. 


[web2py] Re: autofilling (redefining?) a Field value

2011-07-22 Thread pbreit
I'm not sure I totally understand. Wouldn't you need to do this with 
JavaScript?

[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread pbreit
Ah, I see. That could be interesting. Possible to upload the changes as 
patches so we could isolate the differences?

[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Ross Peoples
The changes are all over the place right now. I was hoping to release these as 
a series of patches to make later testing easier. I submitted the mobile 
detection already as issue 346. All of the changes since have been to the 
welcome application, since layout selection is a per app thing.

Assuming the detection patch gets accepted into the trunk, I can attach a copy 
of the welcome app so you can see how the layout switching works. 

I haven't done any work on the view switching yet, but hopefully I can do it 
tonight. Once I get that working, see if I can figure out a way to post it so 
it can get some testing before subitting it to the trunk. 


Re: [web2py] autofilling (redefining?) a Field value

2011-07-22 Thread Bruno Rocha
this - ? http://www.web2pyslices.com/slices/take_slice/85

On Fri, Jul 22, 2011 at 12:56 PM, mart msenecal...@gmail.com wrote:

 Hi,

 I would like to have a table field 'autofill' a value based on another
 field's choice. I would like to have a link displayed depending on the
 user's server name choice. something like this (but obviously this is
 wrong ;) )

 this is the table definition (the last validation line is the issue):

 db.define_table('build',
Field('title'),Field('description',length=256),

 Field('category',requires=IS_IN_DB(db,db.category.name)),
Field('date','date',default=datetime.datetime.now()),

 Field('URL','text'),Field('buildServer',requires=IS_IN_DB(db,
 db.buildserver.name)))

 db.category.name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'category.name
 ')]
 db.build.title.requires=[IS_NOT_EMPTY()]
 db.build.description.requires=IS_NOT_EMPTY()
 db.build.category.requires=IS_IN_DB(db,'category.id','category.name')
 db.build.date.requires=IS_DATE()
 db.build.URL='http://{0}/blueLite/default/
 index.html'.format(db.build.buildServer)



 if the user fills the form, and chooses a server from the
 'buildServer' field, I would like the 'URL' field to autofill with the
 user's server choice as variable. So something like the last
 validation line above ( db.build.URL='http://{0}/blueLite/default/
 index.html'.format(db.build.buildServer) )

 Any ideas how this can work?

 thanks,
 Mart :)




-- 



--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


[web2py] New to programming question

2011-07-22 Thread DanB

I've working with web2py for a little while now (loving it!), and been
poking through a few appliances, especially Instant Press!) to puzzle
out how things work. This is probably a basic Python question, or
maybe it's something about web2py, so here goes.

I noticed that in instant Press, the application uses a top-level
class (superclass?) to load it's modules and their associated models
(the _i2p.py file in the models folder), and this class is
instantiated in db.py. I was trying to follow this pattern, and
noticed that if I don't prefix the file name with an underscore (e.g.
myclass.py), it isn't available, but as soon as I add that underscore
to the filename (e.g. _myclass.py) it works.

Why is this? All I could find in the Python documentation was mention
that functions that begin with an underscore are not loaded during 
from myclass import * .

Thanks in advance!


[web2py] The web2py grid/crud plugin you've always dreamed about!

2011-07-22 Thread Bruno Rocha
Hi,

I present you PowerGrid Plugin (now in beta 0.1) [
http://labs.blouweb.com/PowerGrid/]

What is it?

A plugin to show, manage and paginate data
It works with paginated JSON callbacks, you can use web2py DAL's Query or
Table, or you can create your own callback returning the desired JSON or
JSONP

What is has in special?
- Based on Jquery templates
- Server side pagination loads records on demand
- Ajax Caching option
- Programable in pure Python  web2py
- You can pass JS callbacks to the event handlers
- Can show images with Virtual Fields
- has button system
- totally integrated with CRUD
- Easy to integrate with Auth
- Can be used to manage a site content (a CMS admin page)
- can be used to create any kind of paginated data view

Changelog:
- Some issues solved
- Tested in Windows, Linux, I.E, Opera, Chrome, FF
- Better default layout

Beta:
- Needs tests with different datasources
- Need to be tested on GAE
- Need to test multiple on the same page
- Need to test wotking with another UI libs

EXAMPLES:
images - http://labs.blouweb.com/PowerGrid/default/withimages
dataGRid - http://labs.blouweb.com/PowerGrid/default/onlydata
Buttons - http://labs.blouweb.com/PowerGrid/default/buttons
Scrolling - http://labs.blouweb.com/PowerGrid/default/scroll
Customization: http://labs.blouweb.com/PowerGrid/default/nocontrol /
http://labs.blouweb.com/PowerGrid/default/noadd /
http://labs.blouweb.com/PowerGrid/default/nosearch
Default search system:
http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrariwhere=manufacturer
SubGrids: http://labs.blouweb.com/PowerGrid/default/gridinpopup
JavaScript callbacks: http://labs.blouweb.com/PowerGrid/default/jscallbacks
Custom templates: http://labs.blouweb.com/PowerGrid/default/blog (a blog
created with it)


DOCUMENTATION:
Is being writen in home page
http://labs.blouweb.com/PowerGrid/default/index (in
the grid)
source example app is well commented with options.

IT USES:
http://labs.blouweb.com/PowerGrid/default/about


Comments:
http://labs.blouweb.com/PowerGrid/default/support


Get it:
http://labs.blouweb.com/PowerGrid/default/get


!!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!

Thanks if you can test and report on BitBucker or omments page.


Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]
[ Aprenda a programar: http://CursoDePython.com.br ]
[ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
[ Consultoria em desenvolvimento web: http://www.blouweb.com ]


Re: [web2py] Re: Just started web development

2011-07-22 Thread Furqan Rauf
Sure, I would love to do it.
Thanks

On Fri, Jul 22, 2011 at 4:39 PM, cjrh caleb.hatti...@gmail.com wrote:

 On Friday, 22 July 2011 23:02:28 UTC+2, Furqan wrote:

 Also I want to help develop and enrich the web2py framework so feel free
 to throw some task at me, I am a newbie programmer but willing to learn.


 Excellent.  This places you in a good position to evaluate whether the
 documentation (web2py.com/book) is adequate for persons new to web2py.
  While learning from the book, it would be great if you could point out here
 in this group any sections in the book that are not clear, or misleading, or
 even outright incorrect.  If you follow the book's examples, and your
 attempt doesn't work because of some subtlety that the book glosses over, or
 fails to emphasize appropriately, then please do mention those too.  I am
 particularly curious as to whether the book is suitable to newcomers.  It
 really becomes impossible to tell after one has worked with the framework
 for a while.




-- 
*-Furqan Rauf*
*Do you love your creator? Love your fellow-beings first. -Prophet Muhammad
*
*http://www.amway.com/furqanrauf*


Re: [web2py] New to programming question

2011-07-22 Thread Martín Mulone
Web2py execute the models in alphabetical order, some people put number
before the name of the model ex: 0config.py , I put underscore ex:
_config.py. There are no other reason, is not a python thing . Web2py have
many changes since instant press was written some things can be rewrite in
different way or improved.

2011/7/22 DanB dran...@heximperia.com


 I've working with web2py for a little while now (loving it!), and been
 poking through a few appliances, especially Instant Press!) to puzzle
 out how things work. This is probably a basic Python question, or
 maybe it's something about web2py, so here goes.

 I noticed that in instant Press, the application uses a top-level
 class (superclass?) to load it's modules and their associated models
 (the _i2p.py file in the models folder), and this class is
 instantiated in db.py. I was trying to follow this pattern, and
 noticed that if I don't prefix the file name with an underscore (e.g.
 myclass.py), it isn't available, but as soon as I add that underscore
 to the filename (e.g. _myclass.py) it works.

 Why is this? All I could find in the Python documentation was mention
 that functions that begin with an underscore are not loaded during 
 from myclass import * .

 Thanks in advance!




-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] The web2py grid/crud plugin you've always dreamed about!

2011-07-22 Thread Lucas D'Avila
Parabéns Bruno, muito bom!
pretendo usa-lo nos próximos projetos.

2011/7/22 Bruno Rocha rochacbr...@gmail.com

 Hi,

 I present you PowerGrid Plugin (now in beta 0.1) [
 http://labs.blouweb.com/PowerGrid/]

 What is it?

 A plugin to show, manage and paginate data
 It works with paginated JSON callbacks, you can use web2py DAL's Query or
 Table, or you can create your own callback returning the desired JSON or
 JSONP

 What is has in special?
 - Based on Jquery templates
 - Server side pagination loads records on demand
 - Ajax Caching option
 - Programable in pure Python  web2py
 - You can pass JS callbacks to the event handlers
 - Can show images with Virtual Fields
 - has button system
 - totally integrated with CRUD
 - Easy to integrate with Auth
 - Can be used to manage a site content (a CMS admin page)
 - can be used to create any kind of paginated data view

 Changelog:
 - Some issues solved
 - Tested in Windows, Linux, I.E, Opera, Chrome, FF
 - Better default layout

 Beta:
 - Needs tests with different datasources
 - Need to be tested on GAE
 - Need to test multiple on the same page
 - Need to test wotking with another UI libs

 EXAMPLES:
 images - http://labs.blouweb.com/PowerGrid/default/withimages
 dataGRid - http://labs.blouweb.com/PowerGrid/default/onlydata
 Buttons - http://labs.blouweb.com/PowerGrid/default/buttons
 Scrolling - http://labs.blouweb.com/PowerGrid/default/scroll
 Customization: http://labs.blouweb.com/PowerGrid/default/nocontrol /
 http://labs.blouweb.com/PowerGrid/default/noadd /
 http://labs.blouweb.com/PowerGrid/default/nosearch
 Default search system:
 http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrariwhere=manufacturer
 SubGrids: http://labs.blouweb.com/PowerGrid/default/gridinpopup
 JavaScript callbacks:
 http://labs.blouweb.com/PowerGrid/default/jscallbacks
 Custom templates: http://labs.blouweb.com/PowerGrid/default/blog (a blog
 created with it)


 DOCUMENTATION:
 Is being writen in home page
 http://labs.blouweb.com/PowerGrid/default/index (in the grid)
 source example app is well commented with options.

 IT USES:
 http://labs.blouweb.com/PowerGrid/default/about


 Comments:
 http://labs.blouweb.com/PowerGrid/default/support


 Get it:
 http://labs.blouweb.com/PowerGrid/default/get


 !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
 BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!

 Thanks if you can test and report on BitBucker or omments page.


 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]




-- 
*Lucas D'Avila*
https://github.com/lucasdavila


Re: [web2py] New to programming question

2011-07-22 Thread DanB
Martin,

Thanks so much for the quick response! That makes a few things a lot more 
clear, thank you.

I really like a lot of the things the InstantPress does, and as I'm a rather 
novice programmer, I thought I would work through your example to learn more, 
and maybe build some things I've got in mind.

If I may, let me ask this: with the changes to web2py, from a high-level design 
perspective, how would you change the code and/or structure of Instant Press if 
you wrote it now? It seems to work well, and is farily modular in its own way. 


Re: [web2py] The web2py grid/crud plugin you've always dreamed about!

2011-07-22 Thread Furqan Rauf
looks sweet

On Fri, Jul 22, 2011 at 6:23 PM, Lucas D'Avila lucass...@gmail.com wrote:

 Parabéns Bruno, muito bom!
 pretendo usa-lo nos próximos projetos.

 2011/7/22 Bruno Rocha rochacbr...@gmail.com

 Hi,

 I present you PowerGrid Plugin (now in beta 0.1) [
 http://labs.blouweb.com/PowerGrid/]

 What is it?

 A plugin to show, manage and paginate data
 It works with paginated JSON callbacks, you can use web2py DAL's Query or
 Table, or you can create your own callback returning the desired JSON or
 JSONP

 What is has in special?
 - Based on Jquery templates
 - Server side pagination loads records on demand
 - Ajax Caching option
 - Programable in pure Python  web2py
 - You can pass JS callbacks to the event handlers
 - Can show images with Virtual Fields
 - has button system
 - totally integrated with CRUD
 - Easy to integrate with Auth
 - Can be used to manage a site content (a CMS admin page)
 - can be used to create any kind of paginated data view

 Changelog:
 - Some issues solved
 - Tested in Windows, Linux, I.E, Opera, Chrome, FF
 - Better default layout

 Beta:
 - Needs tests with different datasources
 - Need to be tested on GAE
 - Need to test multiple on the same page
 - Need to test wotking with another UI libs

 EXAMPLES:
 images - http://labs.blouweb.com/PowerGrid/default/withimages
 dataGRid - http://labs.blouweb.com/PowerGrid/default/onlydata
 Buttons - http://labs.blouweb.com/PowerGrid/default/buttons
 Scrolling - http://labs.blouweb.com/PowerGrid/default/scroll
 Customization: http://labs.blouweb.com/PowerGrid/default/nocontrol /
 http://labs.blouweb.com/PowerGrid/default/noadd /
 http://labs.blouweb.com/PowerGrid/default/nosearch
 Default search system:
 http://labs.blouweb.com/PowerGrid/default/defaultsearch?what=Ferrariwhere=manufacturer
 SubGrids: http://labs.blouweb.com/PowerGrid/default/gridinpopup
 JavaScript callbacks:
 http://labs.blouweb.com/PowerGrid/default/jscallbacks
 Custom templates: http://labs.blouweb.com/PowerGrid/default/blog (a blog
 created with it)


 DOCUMENTATION:
 Is being writen in home page
 http://labs.blouweb.com/PowerGrid/default/index (in the grid)
 source example app is well commented with options.

 IT USES:
 http://labs.blouweb.com/PowerGrid/default/about


 Comments:
 http://labs.blouweb.com/PowerGrid/default/support


 Get it:
 http://labs.blouweb.com/PowerGrid/default/get


 !!! BETA VERSION, SOME THINGS CAN CRASH, THE SERVER IS A BIT SLOW, IT WILL
 BE VERY MORE QUICKLY IN A GOOD SERVER OR GAE !!!

 Thanks if you can test and report on BitBucker or omments page.


 Bruno Rocha
 [ About me: http://zerp.ly/rochacbruno ]
 [ Aprenda a programar: http://CursoDePython.com.br ]
 [ O seu aliado nos cuidados com os animais: http://AnimalSystem.com.br ]
 [ Consultoria em desenvolvimento web: http://www.blouweb.com ]




 --
 *Lucas D'Avila*
 https://github.com/lucasdavila




-- 
*-Furqan Rauf*
*Do you love your creator? Love your fellow-beings first. -Prophet Muhammad
*
*http://www.amway.com/furqanrauf*


[web2py] Web2py talk proposal - Codebits 2011

2011-07-22 Thread blackthorne
Hi,
just submitted a talk proposal on web2py for the Codebits 2011 event
yield in Lisbon, Portugal (November). I invite you to support me with
your votes at and join me if you're close by: 
http://codebits.eu/intra/s/proposal/152

So, don't forget to put your thumbs up to my talk proposal and hope to
see you there!


[web2py] Re: GAE users - SDK upgrade breaks your test database

2011-07-22 Thread howesc
i was wrong, the above does not quite work.

but our friends from the app engine team have told us:

Another way to deal with it is to use the  --default_partition= flag 
rather than using an older version of the sdk. 

http://code.google.com/appengine/forum/?place=topic%2Fgoogle-appengine%2FkJGPWT4fhgw%2Fdiscussion

cfh


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-22 Thread Luis Goncalves
Thanks, Anthony!  

I still haven't figured it out completely (mostly because I don't know very 
much about CSS and someone else is dealing with that part of the project). 

Thanks!
Luis.


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-22 Thread Anthony
Also, if you need more control, see 
http://web2py.com/book/default/chapter/07#Custom-forms.

On Friday, July 22, 2011 9:59:24 PM UTC-4, Luis Goncalves wrote:

 Thanks, Anthony!  

 I still haven't figured it out completely (mostly because I don't know very 
 much about CSS and someone else is dealing with that part of the project). 

 Thanks!
 Luis.



[web2py] Re: autofilling (redefining?) a Field value

2011-07-22 Thread mart
Thanks guys for the replies! :)

so, I was looking to have a field updated while the form was being
filled out, which didn't work very well ;) . So I went for the more
obvious solution... i put it in the view :)

lia href={='http://{0}/blueLite/default/
index.html'.format(build.buildServer)}}{{=build.buildServer}}/a/
li


BTW - this is for another adaptation of Massimo's 'cookBook'.. instead
of storing recipes by category, it stores and displays build servers
and build definitions by build category - still can't get over how
many uses there are for that app! :)

Thanks again,
mart :)

On Jul 22, 6:11 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 this - ?http://www.web2pyslices.com/slices/take_slice/85









 On Fri, Jul 22, 2011 at 12:56 PM, mart msenecal...@gmail.com wrote:
  Hi,

  I would like to have a table field 'autofill' a value based on another
  field's choice. I would like to have a link displayed depending on the
  user's server name choice. something like this (but obviously this is
  wrong ;) )

  this is the table definition (the last validation line is the issue):

  db.define_table('build',
                 Field('title'),Field('description',length=256),

  Field('category',requires=IS_IN_DB(db,db.category.name)),
                 Field('date','date',default=datetime.datetime.now()),

  Field('URL','text'),Field('buildServer',requires=IS_IN_DB(db,
  db.buildserver.name)))

  db.category.name.requires=[IS_NOT_EMPTY(),IS_NOT_IN_DB(db,'category.name
  ')]
  db.build.title.requires=[IS_NOT_EMPTY()]
  db.build.description.requires=IS_NOT_EMPTY()
  db.build.category.requires=IS_IN_DB(db,'category.id','category.name')
  db.build.date.requires=IS_DATE()
  db.build.URL='http://{0}/blueLite/default/
  index.html'.format(db.build.buildServer)

  if the user fills the form, and chooses a server from the
  'buildServer' field, I would like the 'URL' field to autofill with the
  user's server choice as variable. So something like the last
  validation line above ( db.build.URL='http://{0}/blueLite/default/
  index.html'.format(db.build.buildServer) )

  Any ideas how this can work?

  thanks,
  Mart :)

 --

 --
 Bruno Rocha
 [ About me:http://zerp.ly/rochacbruno]
 [ Aprenda a programar:http://CursoDePython.com.br]
 [ O seu aliado nos cuidados com os animais:http://AnimalSystem.com.br]
 [ Consultoria em desenvolvimento web:http://www.blouweb.com]


[web2py] Re: DISCUSSION: Dual Desktop/Mobile Functionality

2011-07-22 Thread Ross Peoples
After some hacking on the welcome application, I have finally got this 
working! I attached a screenshot of a /default/test function I created. 
That URL uses the test.html view when viewed on the desktop browser, and 
the same URL uses the test.mobile.html view when viewed using the iPhone 
Simulator. I chose to go with .mobile.html instead of just .mobile for 
the extension because it still gives you the syntax highlighting in text 
editors when it still ends in .html.

I hope Massimo accepts my mobile browser detection patch so that I can 
attach the new welcome application that supports this new desktop/mobile 
dual mode. I'd certainly like a few testers before I submit a formal patch 
with the new dual site support.

https://lh6.googleusercontent.com/-gN9BQwrdyj8/TiozTFkzVtI/AEI/Fd5eWevYUBE/Screen%252520Shot%2525202011-07-22%252520at%25252010.27.09%252520PM.png



[web2py] how to iterate efficiently (memory-wise) through a huge DAL query

2011-07-22 Thread Luis Goncalves
I am trying to use web2py's DAL for a project that is not a webapp.

I have a database with about 8M entries, and I want to process the data.

Suppose I create a query that returns a lot of results:
extreme case example:

q = db.table.id0

How do I iterate through all the results of  a  large query, q, *without*having 
to retrieve all the data to memory?

Is there something better than:

# q = a db query that returns a huge number of results
n = q.count()
s = db(q)

for i in range(1,n):
r = s.select( limitby=(i,1)).first()
# do something with r
...

I've tried this out (interactively, to see what is happening),
and when I get to i=2,

s.select( limitby=(2,1)).first()

the computer starts to swap and hangs for minutes.

So my question, again, is:

Is there an efficient way to iterate through a large query (or set = 
db(query) )
that avoids overloading the system memory?

Thanks,
Luis.


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-22 Thread Anthony
On Friday, July 22, 2011 10:29:25 PM UTC-4, Luis Goncalves wrote: 

 Thanks!   Also, I think we need to make better/smarter/proper use of the 
 #id table-field entries of each field!

 
Do you have an example?
 
Anthony