Re: [web2py] Re: Extracting row id from url using request.args

2012-11-19 Thread Johann Spies
On 19 November 2012 14:58, Michael Hall  wrote:

> Hi Villas
>
> I like the idea of using a var instead of args but I am still uncertain of
> how I get the ID of the current record I am viewing/editing in smartgrid.
>
>
Here is an example of code I am using where 'auid' represents the id of the
author record:

  links = [lambda row: (A(B(T('Edit')), _target = "_blank",
_href = URL(r = request,
c = 'authors',
f = 'edit_author',
vars = dict(auid = str(row[
db.akb_authors.id])]
query = ...
fields = [list of fields]

I then call the grid with SQLFORM.grid(query, fields=fields, links=links)


Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] global name 'T' / 'auth' / 'request' is not defined, but i'm in a model file...

2012-11-19 Thread Johann Spies
On 19 November 2012 15:53, Cédric Mayer  wrote:

>
>   File 
> "C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/models/a34_lact_running_modes.py"
>  
> ,
>  line 43, in on_end
> session.flash = T('Serie finished! Thank you!')
> NameError: global name 'T' is not defined
>
> de.on_end()
>
> As you see, a34_running_modes.py is in the 'models' folder. But a function
> from it called from the controller doesn't know of 'T' which is global !
> Previously I had the same error in some other functions with 'auth'
> (defined in a12_db.py, so still before) and 'request', which I solved by
> passing 'auth' or 'request' as function arguments (even if I find it not
> very nice...), as they are available in the controller function.
>
> But if even T is not known, I cannot pass all usual global variables as
> arguments to every function present in 'models' folder.
>
> Do I miss something ? Like a "what-to-check-if-you want-to-upgrade web2py"
> documentation ? (even if I thought web2py was fully backward compatible,
> this is why I choose it)
>
>
The problem might be the name of your model.  If I remember correctly the
models are imported in alphabetical order.  In the default db.py (like in
the welcome app) some important stuff gets imported that should happen
before other models are loaded.

As an experiment try a changed name for your model which starts with a
character > 'd'.

Otherwise do import the necessary stuff from gluon in your model.

e.g.

from gluon import T

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





Re: [web2py] Re: we should support this in DAL

2012-11-19 Thread Simon Ashley
In the not to distant future we need to refactor reasonable large SQL 
databases.
Current open source choices are limited to MySQL and PostgreSQL. 
(trying to avoid vendor lock in issues).
 
Interest in this thread is as a prompt to explore nosql pros and cons.

Both SQL options are mature, well developed etc, but are they using legacy 
thinking? 
(i.e. originally developed for smaller discrete client/ server systems 
rather than where we are today)

Have always found it a pain to refactor existing tables in a production 
environment i.e. if a client wants additional fields, field sizes 
increased, or conditional fields 6 months into the deployment cycle. Sure 
you can do it with relational databases, but sooner or later you have an 
explosion of additional tables, multiple joins on hard to index or de 
normalised structures. 

Can think of one case where a single manifesting table has spawned 25 child 
tables which would be better managed as a single entity. Reports with 
queries joining 10 or more tables are common. Sure you can alter/ drop and 
load tables but its gets difficult over disconnected databases (i.e. 
different sites, different data sets but where schema has to be consistent).

Other complications occur with multi dimensional analysis, pivot tables, 
performance issues, (excessive?) requirements for temporary and posting 
tables. 
It occurs in writing this that maybe we also need to include chart 
databases such as OrientDB.

Even with nosql, believe a schema is a must, but there could be a option of 
a loosely coupled schema (maybe a view superset allowing manipulation and 
updates). Have been using this with SQLite to archive old field formats 
during development. While this can be done with the current DAL, aspects 
can get untidy.

Nothing here is a deal breaker between the choice of SQL/ no sql, but we 
also have to look at developer productivity issues.

It's new territory, and open to comments and criticism. 

>
>

-- 





[web2py] Re: wxpython app using web2py username and password

2012-11-19 Thread dlypka
Here is a revision to Step 2:
2. In main.py starting around line 526

# ##
# try load session or create new session file
# ##

if not env.web2py_disable_session:
session.connect(request, response)


change to

# ##
# try load session or create new session file
# ##

session.connect(request, response, db)  # dlypka mod - 
added ,db

newsessionid = 0 # dlypka mod
if 'sessioncookieval_fromweb2py' in request.post_vars or 
'checkIsLoggedIn' in request.post_vars :  # dlypka mod
newsessionid = session._try_store_in_db(request, 
response) # dlypka mod

if newsessionid > 0:   # dlypka mod   
isSessionRecordCreated = True;  # dlypka mod

On Thursday, November 15, 2012 11:03:27 AM UTC-6, Jim S wrote:
>
> Hi, I'm creating a little desktop app as a companion to a web app I 
> created with web2py.  I'm using the default auth_user tables so I have an 
> email address and encrypted password I can use for my desktop user to 
> login.  I've been looking for the code that does the login in web2py but 
> can't seem to find it.  Is there a recipe somewhere that would show me how 
> to mimic the encryption that web2py uses so I compare encrypted passwords 
> and use them to allow my desktop app users to login?
>
> -Jim
>

-- 





[web2py] PDF to directory

2012-11-19 Thread Paul Rykiel
Greetings...
 
I am using PYFPDF to create my pdf's ... all is great, but instead of 
automatically creating the PDF, I would like the system to prompt the user 
to enter the directory where they want the PDF saved to? Can this be done, 
this would be a big help.
 
Thanks in advance for your assistance
Regards,
 
 

-- 





[web2py] images folder

2012-11-19 Thread Paul Rykiel
Hi all,
 
What folder inside of Web2py is the best place to store and retreive images 
for things like LOGO's and ICONS?
Please advise.
 
Thank you!

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread dlypka
I had to work around this problem in tools.py in my web2py 1.9x code.
Maybe this issue is still in 2.x

@staticmethod

def get_or_create_key(filename=None):

request = current.request

if not filename:

filename = os.path.join(request.folder,'private','auth.key')

if os.path.exists(filename):

key = open(filename,'r').read().strip()

else:

key = web2py_uuid()

*#* open(filename,'w').write(key) *# dlypka workaround - this crashes on 
GAE, not allowing to write to a file!!*

return key

--

Also a similar issue here: in In admin\controllers\default.py

#Get crontab

cronfolder = apath('%s/cron' % app, r=request)

if not os.path.exists(cronfolder): os.mkdir(cronfolder)

crontab = apath('%s/cron/crontab' % app, r=request)

#if not os.path.exists(crontab): # dlypka patch for GAE - safe_write() 
fails on gae

#safe_write(crontab, '#crontab')


On Monday, November 19, 2012 9:22:36 PM UTC-6, Massimo Di Pierro wrote:
>
> Please open a ticken about this. I will be able to look at it later 
> tomorrow.
>
> On Monday, 19 November 2012 10:57:27 UTC-6, Sebastian Cambeo wrote:
>>
>> might it be, that "users.create_login_url(request.env.path_info)" in 
>> "check_credentials" needs some kind of file access?
>>
>> Anyhow this request appears to trigger the error
>>
>

-- 





[web2py] Re: Question about response.menu !! ...

2012-11-19 Thread Massimo Di Pierro
A menu is a lust a list which you display with {{=MENU(menu)}}. If you put 
the right stuff in the menu it should display right.



On Monday, 19 November 2012 20:25:47 UTC-6, Don_X wrote:
>
> In the cookbook it says that we can have more than one response.menu in 
> the same view !
>
> How would I go about it ? ...
>
> I created another response.menu by naming it in the menu model file :   
> response.menubar = [ ]
>
> and then expanded on its own menu items  inside the __def( )  function   
>  by doing  5 response.menubar.append(  )  instructions to show 5 
> dropdown items ...
>
> the menu did not come up ... ( it shows as a whole bunch of jeebris ! 
> ) ...
>
> How do I go about creating another response.menu in the same view ??? ...
>
> please advise 
>
> Don
>

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Massimo Di Pierro
Please open a ticken about this. I will be able to look at it later 
tomorrow.

On Monday, 19 November 2012 10:57:27 UTC-6, Sebastian Cambeo wrote:
>
> might it be, that "users.create_login_url(request.env.path_info)" in 
> "check_credentials" needs some kind of file access?
>
> Anyhow this request appears to trigger the error
>

-- 





[web2py] Re: error export represet

2012-11-19 Thread Massimo Di Pierro
OK. For now do:

db.periodo_academico.sistema.represent = lambda v, row=None: 
mi_represent(v,  _status)

but please open a ticket about this pointing to this thread. This may be a 
web2py bug.

On Monday, 19 November 2012 09:44:28 UTC-6, www.diazluis.com wrote:
>
> example:
>
> b50_periodo_academico.py:
>
> db.define_table('periodo_academico',
> Field('carrera',db.carrera),
> Field('codigo', 'string', length=16), # 
> Field('nombre', 'string', length=64, default='Carrera, Nombre del 
> Periodo'), # odontologia 2013-2014
> Field('fecha_ini', 'date'),
> Field('fecha_fin', 'date'),
> Field('sistema', 'string', length=1, default='1'),
>
>
> #auditoria
> Field('ip', 'string', length=64,  default=request.client, 
> update=request.client, writable=False, readable=False),
> Field('fecha', 'date',default=request.now, update=request.now, 
> writable=False, readable=False),
> Field('user_update', db.auth_user, default=id_user, update=id_user, 
> writable=False, readable=False),
>
> format = '%(nombre)s'
> )
>
> # requires
> db.periodo_academico.codigo.requires = 
> db.periodo_academico.nombre.requires = _requires_nombre
> db.periodo_academico.sistema.requires = IS_IN_SET(_status, zero=None)
>
> #represent
> db.periodo_academico.sistema.represent = lambda v, row: mi_represent(v, 
>  _status)
>
>
>
>
> db_base_config.py:
>
> _status = {
> '1':'Cerrado',
> '2':'Activo',
> '3':'Uso interno',
> }
>
>
> def mi_represent(v, almacen, row=None):
> mostrar = None
> try:
> mostrar = almacen[v]
> except:
> mostrar = '---'
> return mostrar
>
>
>
> El viernes, 16 de noviembre de 2012 17:45:23 UTC-4:30, Massimo Di Pierro 
> escribió:
>>
>> some where you have a Field(...,represent=something)
>>
>> and something takes two arguments, not one. Can you show us the model?
>>
>> On Friday, 16 November 2012 08:51:32 UTC-6, www.diazluis.com wrote:
>>>
>>> {{
>>> import cStringIO
>>> stream=cStringIO.StringIO()
>>> estudiante_arancel_rows.export_to_csv_file(ofile=stream, represent=True)
>>> response.headers['Content-Type']='application/vnd.ms-excel'
>>> response.headers['Content-Disposition'] =  "attachment; filename=%s" % 
>>> 'data_sga.csv'
>>> response.write(stream.getvalue(), escape=False)
>>> }}
>>>
>>>
>>> Traceback (most recent call last):
>>>   File "/home/diazluis2007/web2py/gluon/restricted.py", line 212, in 
>>> restricted
>>> exec ccode in environment
>>>   File 
>>> "/home/diazluis2007/web2py/applications/sga/views/estudiante_arancel/exportar_excel.html",
>>>  
>>> line 3, in 
>>> stream=cStringIO.StringIO()
>>>   File "/home/diazluis2007/web2py/gluon/dal.py", line 9249, in 
>>> export_to_csv_file
>>> value = field.represent(value)
>>> TypeError: () takes exactly 2 arguments (1 given)
>>>
>>>  web2py: 2.2.1
>>>
>>

-- 





[web2py] Question about response.menu !! ...

2012-11-19 Thread Don_X
In the cookbook it says that we can have more than one response.menu in the 
same view !

How would I go about it ? ...

I created another response.menu by naming it in the menu model file :   
response.menubar = [ ]

and then expanded on its own menu items  inside the __def( )  function   
 by doing  5 response.menubar.append(  )  instructions to show 5 
dropdown items ...

the menu did not come up ... ( it shows as a whole bunch of jeebris ! ) 
...

How do I go about creating another response.menu in the same view ??? ...

please advise 

Don

-- 





[web2py] Re: custom built login form

2012-11-19 Thread Daniele
Ah ok I just took a look at the HTML and saw that my code conflicts with 
what web2py is generating.
Basically there's a form within a form being constructed, so it looks like 
this:



To avoid this, how can I tell web2py that the login form's style has to be 
form-horizontal?
That way it can generate the HTML automagically.



On Wednesday, August 15, 2012 6:51:12 AM UTC+1, shartha wrote:
>
> Hello, 
> Quick question:
> Instead of {{=auth.login()}}, I am using the following to be able to 
> customize my login form. However the resulting form does not work and I 
> cannot login with the same username/password that enable me to login if I 
> had used {{=auth.login()}} -- I get the flash error: Invalid Login.
>
> Could someone please tell me what's possibly going wrong? Thanks!
>
> {{form=auth.login()}}
> {{=form.custom.begin}} 
> Username:
> {{=form.custom.widget.username}}
> 
> Password:
> {{=form.custom.widget.password}}
> {{=form.custom.submit}} 
> {{=form.custom.end}} 
>

-- 





[web2py] Re: changing the look of a form

2012-11-19 Thread Daniele
You're going to have to change the style via CSS. If it's an inbuilt form 
in web2py like the login one, good luck :P you will have to use the custom 
form widgets and do a bunch of somersaults. Try following this guide, it 
may help:
http://web2py.com/book/default/chapter/07#FORM

On Wednesday, November 14, 2012 8:58:45 PM UTC, Hector Magnanao wrote:
>
> how do you change the look of a form (i.e. background color, fonts, 
> etc...) ?

-- 





[web2py] Re: How to get register_next to move on to the desired URL

2012-11-19 Thread Daniele
Here's my registration form:

db.define_table(
auth.settings.table_user_name,
Field ('email', 
length=128, default=''),
Field ('password', 
'password', length=512, readable=False),
Field ('password_verify', 
'password', length=512, readable=False),
Field 
('registration_time', 
'datetime', requires=IS_DATETIME 
(), writable=False, 
readable=False, default=request 
.utcnow),
Field 
('registration_key', 
length=512, writable=False, readable=False, default=''),
Field ('registration_id', 
length=512, writable=False, readable=False, default='')
)

custom_auth_table = db[auth.settings.table_user_name] #get the custom_auth_table
custom_auth_table.email.requires = [
IS_NOT_EMPTY 
(error_message='Please 
input an email address'),
IS_EMAIL 
(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB 
(db, 
custom_auth_table.email)]
custom_auth_table.password.requires = [
IS_NOT_EMPTY 
(error_message='Please 
type a password'),
IS_STRONG (min=8, 
special=0, upper=1),
CRYPT ()]
custom_auth_table.password_verify.requires = [
IS_NOT_EMPTY 
(error_message='Please 
retype your password'),
IS_EQUAL_TO 
(request 
.vars.password, 
error_message='Passwords do not match'),
CRYPT ()]

auth.settings.table_user = custom_auth_table # tell auth to use 
custom_auth_table

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)

auth.settings.registration_requires_verification = True

#To automatically login people after registration, even if they have not 
completed the email verification process, set the following to True
auth.settings.login_after_registration = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.messages.verify_email = 'Click on the link http://' + \
request .env.http_host 
+ \
URL (r=request 
,f='user',args=['verify_email'])
 + \
'/%(key)s to verify your email'
auth.messages.reset_password = 'Click on the link http://' + \
request .env.http_host 
+ \
URL (r=request 
,f='user',args=['reset_password'])
 + \
'/%(key)s to reset your password'

auth.settings.register_next = URL 
('dashboard')
auth.settings.login_url = URL 
('login')
auth.settings.login_next = URL 
('dashboard')
auth.settings.logout_next = URL 
('index')


but when I try registering a new user, it does not redirect to the 
dashboard as I'd like it to.

On Sunday, November 18, 2012 10:51:14 PM UTC, Daniele wrote:
>
> Hey guys, I would like to set register_next to move on to a URL upon 
> successful registration. However, it seems to be redirecting me to the 
> login page right now. I believe this is because I have 
>
> @auth.requires_login()
> def mypage:
>
> in the controller. How can I make it so that when a user registers, the 
> page automatically is redirected to a page I specify?
>
> Thanks!
>

-- 





[web2py] Re: How to get register_next to move on to the desired URL

2012-11-19 Thread Daniele
I had already tried that but it doesn't seem to be working for me. Could 
this be because I am using a custom sign up form? The registration is 
working properly though, which is odd...



On Monday, November 19, 2012 4:45:52 PM UTC, peter wrote:
>
>
> # Instructions: Copy all of this into your db.py, and make the one change 
> in layout.html
>
> # Solution: how to have a user redirected to a page AFTER register
> # in this example, the URL('user/profile') will be used.
>
>
> # app name: AuthRedirect  <- just a NEW application, with no modication
> # web2py Version 2.2.1 (2012-10-21 16:57:04) stable
>
> # - - - - -
> # in layout.html view, modify the line:
> # {{='auth' in globals() and 
> auth.navbar(mode="dropdown") or ''}}
> # to
> # {{='auth' in globals() and 
> auth.navbar(mode="dropdown",referrer_actions=None) or ''}}
> # this will cause the URL not to display
> # 
> http://127.0.0.1:8000/AuthRedirect/default/user/login?_next=/AuthRedirect/default/index
>  
> # but rather
> # http://127.0.0.1:8000/AuthRedirect/default/user/
>
>
> # - - - - -
> # one line of CODE BELOW placed in : 
>
> # /models/db.py - located BELOW the  setting under > ## configure auth 
> policy lines
>
> auth.settings.register_next = URL('user/profile') 
>
> Peter
>
> On Sunday, 18 November 2012 22:51:14 UTC, Daniele wrote:
>>
>> Hey guys, I would like to set register_next to move on to a URL upon 
>> successful registration. However, it seems to be redirecting me to the 
>> login page right now. I believe this is because I have 
>>
>> @auth.requires_login()
>> def mypage:
>>
>> in the controller. How can I make it so that when a user registers, the 
>> page automatically is redirected to a page I specify?
>>
>> Thanks!
>>
>

-- 





[web2py] Re: Time of registration

2012-11-19 Thread Daniele
Massimo, thanks for the reply.
I wasn't able to get it working with what you said but this seems to have 
done the trick instead:

Field('registration_time', 'datetime', requires=IS_DATETIME(), 
writable=False, readable=False, default=request.utcnow),

essentially, the requires field seems to have done some magic that the 
other fields weren't doing.
Thanks!

On Saturday, November 17, 2012 6:57:19 PM UTC, Massimo Di Pierro wrote:
>
> Field('registration_time', 'datetime') is you want the user to fill it in:
>
> Field('registration_time', 'datetime', default=request.now, 
> writable=False, readable=False)
>
> to make it automatic.
>
> On Friday, 16 November 2012 15:44:17 UTC-6, Daniele wrote:
>>
>> Guys I'm wondering when I get someone to register, I'd like to have a 
>> field in my database for the datetime.
>> In my db.py file, I have a Field('registration_time', 'datetime')
>>
>> However, how do I pass in that the time (now) is supposed to be taken 
>> when the user submits the form?? I'm a bit confused about this.
>>
>> Thanks!
>>
>

-- 





[web2py] using Stripe

2012-11-19 Thread greaneym
Hello,

I've looked into stripe.com and it does look like it is easier than google 
wallet to implement. 

When I put the example from the web2py manual into a controller, then the 
charge of whatever amount does communicate with Stripe's server and I can 
see that a charge went through as a test.


How do I see display this example from the manual, section14.10.3, in a 
view?

thank you,
Margaret

-- 





[web2py] Re: Dynamically generating forms from db data which will not be used to store the results in the db

2012-11-19 Thread Amber Doctor
I recently lost some php code and I wanted to redo it in web2py instead of 
php so I am trying to convert from php/mysql to web2py.

In php, I pulled database data for 3 lists.  The 3 lists are 3 different 
kinds of ingredients.  

For each kind of ingredient - alcohol, mixer, garnish - I made a check box. 
 This check box will say "match using ingredient kind X"

Under each checkbox "match using ingredient kind X" there was a list of the 
options.  for example kind alcohol would have under it Vodka, rum, gin, 
etc.   Next to vodka, rum and gin would be another series of checkboxes.  

So in php I said, 
print 
for each item in list alcohol print 

repeat for mixer and garnish

Using a # symbol to represent a checkbox this would be what the screen 
looks like to the user:

# match alcohol#match mixer #match garnish
   #rum #coke #orange
   #vodka  #tonic #lime
   #gin  #orange juice  #lemon

SUBMIT BUTTON

Note a user was permitted to say match mixer and then indicate that he 
wanted to exclude all mixers by not selecting one of the mixer ingredients 
 -- there was also some javascript logic managing checkbox status that 
shouldn't impact the question

Now after submit, back end would say something like 

if match alcohol, then add all checked alcohol.id to a set
if match mixersame 
if match garnish...same

now write a db query with the sets that pulls a list of drinks that make an 
exact match to those ingredient

I ran into the issue of just passing the list to the view in order to 
generate an html form with check boxes and not having the data submit back 
to the controller.  In reading, I came to the belief that I should be 
creating a form in the controller and passing the form to the view instead. 
However, I have only seen static examples of creating a form in the 
controller and my attempts to dynamically generate this form from database 
data have resulted in various errors.

So I want to make the view above from data stored in the database and end 
with the data from the checkboxes stored into a python set (and not alter 
my database data). 

As such, I'm not sure what method I should be doing in order to solve this 
task in web2py. 

I hope that I have defined the problem in a clearer fashion this time.







On Monday, November 19, 2012 12:43:47 PM UTC-6, Amber Doctor wrote:
>
> I'm trying to determine the best way to code the following situation in 
> web2py.
>
> Currently I have a model that has this in it:
>
> db.define_table('ingredient',
> Field('ingredient_name', 'string', required=True),
> Field('kind_ref', 'reference kind', required=True, 
> requires=IS_IN_DB(db, 'kind.id','%(kind_name)s')),
> Field('type_ref', 'reference ingredient_type', 
> required=True, requires=IS_IN_DB(db, 'ingredient_type.id
> ','%(type_name)s')),
> Field('subtype_ref', 'reference ingredient_subtype', 
> required=True, requires=IS_IN_DB(db, 'ingredient_subtype.id
> ','%(subtype_name)s')),
> Field('brand_ref', 'reference ingredient_brand', 
> required=True, requires=IS_IN_DB(db, 'ingredient_brand.id
> ','%(brand_name)s')),
> Field('is_approved', 'boolean', default=True),
> Field('for_match', 'boolean', default=True),
> Field('ingredient_so', 'integer', default=50),
> format='%(ingredient_name)s'
> )
>
> db.define_table('drink_recipe_ingredients',
> Field('drink_recipe_ref', 'reference drink_recipe', 
> requires=IS_IN_DB(db, 'drink_recipe.id','%(drink_recipe_name)s')),
> Field('ingredient_ref', 'reference ingredient', 
> requires=IS_IN_DB(db, 'ingredient.id','%(ingredient_name)s')),
> Field('quantity'),
> Field('unit_ref', 'reference unit', requires=IS_IN_DB(db, '
> unit.id','%(unit_of_measure)s')),
> Field('is_approved', 'boolean', default=True),
> Field('drink_recipe_ingredients_so', 'integer', default=50)
> )
>
>
> from a pseudo use case perspective what I want to do is:
> 1) back end grab 3 sets of data (one for kind, 1,2,3) kinda like: 
>  alcohols = db((db.ingredient.kind_ref=='1') & 
> (db.ingredient.for_match==True) & 
> (db.ingredient.is_approved==True)).select()
> 2) front end display a check box that indicates that you are or are not 
> including information from those three sets of information - "category 
> selector"
> 3) display those three lists of items with check boxes next to each item 
> in the list
> 4) let the user select the check boxes and submit
> 5) in the back end - use the "category selector" and the checked items in 
> each category to create another qu

Re: [web2py] Re: we should support this in DAL

2012-11-19 Thread Niphlod
the main issue for those kind of ideas is to explain your vision of a NoSQL 
adapter..I've seen a lot of "please support a NoSQL DAL" but anyone 
explaining what is he missing from the current DAL. What do you need NoSQL 
DAL for ?
Following some statements raised before: 
a) why DAL doesn't support whateverfunction() the X NoSQL engine provides? 
The point of "unleashing" all features of a particular NoSQL engine is 
basically letting you use db().whatevefunction() instead of 
db._adapter.whateverfunction() ? 
We can't possibly keep up with NoSQL discrepancies even for "common 
features" (i.e. mapreduce). 
Implementing on every adapter all of its own functions instead of letting 
you use the native function call is quite pointless, we're going to face a 
NoSQL adapter that is basically a decorator of native drivers with lots of 
"this functionality is not supported on X, in Y is possible, in Z there are 
some limitations".

DAL was made to abstract common uses of SQL databases that, by design, 
respond with a fixed functionality and a relatively small "fluctuation" 
between the syntax needed to traverse/filter/aggregate the same data. 

b) I don't want to have a schema.
Yes, one of the major "culprit" of SQL vs NoSQL: SQL needs a fixed schema.
This is my personal favourite. Why are you using an MVC framework if you 
don't want models ? 
Let's say the way DAL enforces you to have a "model" (db.define_table()) is 
"restricting" you to use a somewhat "fixed" schema, but you choose x NoSQL 
engine to be "schemaless" and you want to be schema free. 
How should a form be constructed without a model ? How will you define 
validators ? 
There's SQLFORM.factory if you want that kind of functionality, but having 
models keep your code DRY. The second you need to diverge from those 
models, SQLFORM.factory comes to rescue.
And again, you want to change a model and add a field ? DAL surely doesn't 
get in your way: on SQL you get an alter table, on NoSQL you just redefined 
your model.


DAL should only allow you to "shortcut" some common queries (i.e., row by 
id, "key/column contains value", update this row with this value, delete 
this row, etc) all the rest is too much NoSQL specific. the only 
thing missing right now I think is allowing inserting any 
dict/object/mapping through db.table.insert or db(set).update(), but that 
can be added with dedicated "insertdoc", "updatedoc" method skipping 
validators and model mapping adherence.

-- 





[web2py] Re: Dynamically generating forms from db data which will not be used to store the results in the db

2012-11-19 Thread Cliff Kachinske
It's not clear what you are trying to do.

On Monday, November 19, 2012 1:43:47 PM UTC-5, Amber Doctor wrote:
>
> I'm trying to determine the best way to code the following situation in 
> web2py.
>
> Currently I have a model that has this in it:
>
> db.define_table('ingredient',
> Field('ingredient_name', 'string', required=True),
> Field('kind_ref', 'reference kind', required=True, 
> requires=IS_IN_DB(db, 'kind.id','%(kind_name)s')),
> Field('type_ref', 'reference ingredient_type', 
> required=True, requires=IS_IN_DB(db, 'ingredient_type.id
> ','%(type_name)s')),
> Field('subtype_ref', 'reference ingredient_subtype', 
> required=True, requires=IS_IN_DB(db, 'ingredient_subtype.id
> ','%(subtype_name)s')),
> Field('brand_ref', 'reference ingredient_brand', 
> required=True, requires=IS_IN_DB(db, 'ingredient_brand.id
> ','%(brand_name)s')),
> Field('is_approved', 'boolean', default=True),
> Field('for_match', 'boolean', default=True),
> Field('ingredient_so', 'integer', default=50),
> format='%(ingredient_name)s'
> )
>
> db.define_table('drink_recipe_ingredients',
> Field('drink_recipe_ref', 'reference drink_recipe', 
> requires=IS_IN_DB(db, 'drink_recipe.id','%(drink_recipe_name)s')),
> Field('ingredient_ref', 'reference ingredient', 
> requires=IS_IN_DB(db, 'ingredient.id','%(ingredient_name)s')),
> Field('quantity'),
> Field('unit_ref', 'reference unit', requires=IS_IN_DB(db, '
> unit.id','%(unit_of_measure)s')),
> Field('is_approved', 'boolean', default=True),
> Field('drink_recipe_ingredients_so', 'integer', default=50)
> )
>
>
> from a pseudo use case perspective what I want to do is:
> 1) back end grab 3 sets of data (one for kind, 1,2,3) kinda like: 
>  alcohols = db((db.ingredient.kind_ref=='1') & 
> (db.ingredient.for_match==True) & 
> (db.ingredient.is_approved==True)).select()
> 2) front end display a check box that indicates that you are or are not 
> including information from those three sets of information - "category 
> selector"
> 3) display those three lists of items with check boxes next to each item 
> in the list
> 4) let the user select the check boxes and submit
> 5) in the back end - use the "category selector" and the checked items in 
> each category to create another query that pulls information from the 
> drink_recipe_ingredients table
>
> no data gathered is stored in the database.  more than one user can be 
> executing this behavior at the same time.
>
> Any advice on the best way to this would be great.
>

-- 





[web2py] Re: we should support this in DAL

2012-11-19 Thread Simon Ashley
+1 for moving in this direction.

On Saturday, November 17, 2012 10:19:15 PM UTC+10, Massimo Di Pierro wrote:
>
> http://labs.codernity.com/codernitydb/index.html
>

-- 





[web2py] plugin_mptt seems broken under 2.2.1

2012-11-19 Thread Richard
Hello,

Some tests doesn't pass in plugin_mptt, mainly :

line 288, in test_move_child_up_level
node11 node9 2 1 4 5""")

controllers/plugin_mptt.py", line 40, in asserTree
for node in nodes]),
AttributeError: 'Row' object has no attribute 'name'


controllers/plugin_mptt.py", line 256, in test_move_leaf_to_other_tree
node11 node9 2 1 4 5""")


controllers/plugin_mptt.py", line 40, in asserTree
for node in nodes]),
AttributeError: 'Row' object has no attribute 'name'


It seems to be all the same problem...


Richard

-- 





Re: [web2py] Re: Bug? Invalid url puts python into a tight loop - 100% CPU

2012-11-19 Thread Jonathan Lundell
On 19 Nov 2012, at 12:33 PM, Niphlod  wrote:
> it's just only for those who use the parametric router, not for all the 
> web2py installations out there.

You can relax the pattern in routes.py, too.


> 
> Il giorno lunedì 19 novembre 2012 17:17:54 UTC+1, jc ha scritto:
> I have been thinking a little about this. Niphlod's suggestion solves the 
> problem for me at the moment, but isn't there an enormous problem? It seems 
> that any web2py installation can be taken down accidentally or maliciously 
> just by somebody requesting an invalid argument string in the url of the form 
> 'xxX' where the 'x's are valid characters and there are enough of them, 
> and the 'X' is invalid? There must be a lot of vulnerable sites out there.
> 
> It seems to me there is one easy fix which is to just strip out invalid 
> characters before the regex match. You will get collisions, but since the url 
> is invalid anyway, who cares? Or the string could be urlencoded first so that 
> the invalid characters become % encoded?
> 
> 
> On Tuesday, November 13, 2012 7:33:26 PM UTC, Jonathan Lundell wrote:
> On 13 Nov 2012, at 11:20 AM, Niphlod  wrote:
>> I'm definitely not a regex master, but what's the [=.]? part required for ?
> 
> The idea (not mine, fwiw) is that you can have multiple strings of [\w@ -]+ 
> separated or ended (but not begun) with a single . or = (but not multiple 
> ones). My workaround would allow leading or multiple . or =. I think we 
> probably should anyway, since we should be assuming that args are necessarily 
> a file path, which seems to be what's going on there.
> 
> It's trying to prevent stuff like foo/../../../bar.
> 
>> 
>> On Tuesday, November 13, 2012 7:00:32 PM UTC+1, Jonathan Lundell wrote:
>> On 13 Nov 2012, at 9:04 AM, Niphlod  wrote:
>>> seems a problem with the default regex checking for args Let's wait for 
>>> Jonathan
>>> 
>>> >>> import re
>>> >>> mymatch = re.compile(r'([\w@ -]+[=.]?)*$')
>>> >>> mymatch.match('a')
>>> <_sre.SRE_Match object at 0x02A61020>
>>> >>> mymatch.match('A Lccc - Pddd GA Dee (  A).pdf')
>>> 
>>> endless loop of backtracing regex
>> 
>> I don't have a quick fix. The easy solutions involve re elements not 
>> available in Python re (or at least not until 3.1).
>> 
>> A workaround would be to make the pattern a little more lenient: [\w@ -=.]+
>> 
>> If we really want to exclude successive dots or equals, we could make a 
>> separate check for that.
>> 
>> 
> 
> 
> 
> -- 
>  
>  
>  


-- 





Re: [web2py] Re: Bug? Invalid url puts python into a tight loop - 100% CPU

2012-11-19 Thread Niphlod
it's just only for those who use the parametric router, not for all the 
web2py installations out there.

Il giorno lunedì 19 novembre 2012 17:17:54 UTC+1, jc ha scritto:
>
> I have been thinking a little about this. Niphlod's suggestion solves the 
> problem for me at the moment, but isn't there an enormous problem? It seems 
> that any web2py installation can be taken down accidentally or maliciously 
> just by somebody requesting an invalid argument string in the url of the 
> form 'xxX' where the 'x's are valid characters and there are enough of 
> them, and the 'X' is invalid? There must be a lot of vulnerable sites out 
> there.
>
> It seems to me there is one easy fix which is to just strip out invalid 
> characters before the regex match. You will get collisions, but since the 
> url is invalid anyway, who cares? Or the string could be urlencoded first 
> so that the invalid characters become % encoded?
>
>
> On Tuesday, November 13, 2012 7:33:26 PM UTC, Jonathan Lundell wrote:
>>
>> On 13 Nov 2012, at 11:20 AM, Niphlod  wrote:
>>
>> I'm definitely not a regex master, but what's the *[=.]?* part required 
>> for ?
>>
>>
>> The idea (not mine, fwiw) is that you can have multiple strings of [\w@ 
>> -]+ separated or ended (but not begun) with a single . or = (but not 
>> multiple ones). My workaround would allow leading or multiple . or =. I 
>> think we probably should anyway, since we should be assuming that args are 
>> necessarily a file path, which seems to be what's going on there.
>>
>> It's trying to prevent stuff like foo/../../../bar.
>>
>>
>> On Tuesday, November 13, 2012 7:00:32 PM UTC+1, Jonathan Lundell wrote:
>>>
>>> On 13 Nov 2012, at 9:04 AM, Niphlod  wrote:
>>>
>>> seems a problem with the default regex checking for args Let's wait 
>>> for Jonathan
>>>
>>> >>> import re
>>> >>> mymatch = re.compile(r'([\w@ -]+[=.]?)*$')
>>> >>> mymatch.match('a')
>>> <_sre.SRE_Match object at 0x02A61020>
>>> >>> mymatch.match('A Lccc - Pddd GA Dee (  
>>> A).pdf')
>>>
>>> endless loop of backtracing regex
>>>
>>>
>>> I don't have a quick fix. The easy solutions involve re elements not 
>>> available in Python re (or at least not until 3.1).
>>>
>>> A workaround would be to make the pattern a little more lenient: [\w@ 
>>> -=.]+
>>>
>>> If we really want to exclude successive dots or equals, we could make a 
>>> separate check for that.
>>>
>>
>>
>>
>>
>>

-- 





Re: [web2py] Re: we should support this in DAL

2012-11-19 Thread Simon Ashley
Thanks for that. 
Was looking to see how tender the adapter was and how far it could be 
pushed, and that may have answered it.

On Tuesday, November 20, 2012 2:50:20 AM UTC+11, Adi wrote:
>
> Hi Simon, i didn't go too far with DAL and mongo. Managed to get the grid, 
> but as mentioned before had a problem retrieving individual record 
> (document) for view and update. Then I included pymongo, and got needed 
> functionality outside of grid, but didn't have time then to continue 
> working on it. 
>
> Agreed with Vasile that it should be design properly, and then implemented 
> as a nosql version of DAL. Not sure how I could help, if not with coding, 
> then with testing at least?
>
>
> On Sun, Nov 18, 2012 at 5:02 PM, Simon Ashley 
> > wrote:
>
>> What issues are you coming up against with Mongo/ nosql ports and DAL 
>> operations?
>> Interested because we need to start investigating this. 
>>
>>
>> On Sunday, November 18, 2012 12:02:12 PM UTC+10, Adi wrote:
>>>
>>> Definitely would be nice to support NoSQL. 
>>>
>>> I tried the existing DAL with MongoDB and grid worked fine to the point 
>>> of view/edit record. Due to different concepts (sql/nosql) if it's hard to 
>>> keep them in a same DAL, maybe there could be a separate layer for NoSQL. 
>>>
>>> I would be glad to test lots in this area, since I'm trying to port 4-5M 
>>> records into MongoDB, and currently I use web2py with pymongo for that.
>>>
>>>
>>> On Saturday, November 17, 2012 7:19:15 AM UTC-5, Massimo Di Pierro wrote:

 http://labs.codernity.com/**codernitydb/index.html

>>>  -- 
>>  
>>  
>>  
>>
>
>
>
>  

-- 





Re: [web2py] Re: No module named xxx Ubuntu

2012-11-19 Thread António Ramos
i moved my app to web2py2.XX and it works now!

thank you
António

2012/11/19 Mandar Vaze 

> if pycall is under applications/myapp/modules, then try restarting web2py
> When I created a new file under the modules folder, web2py couldn't
> import until it was restarted
>
> See if it helps
>
> -Mandar
>
>
> On Thursday, November 15, 2012 5:38:27 PM UTC+5:30, Ramos wrote:
>>
>> Hello
>> i have web2py running in Ubuntu 12.04
>>
>> i installed a module Pycall as root
>>
>> On the ubuntu console i can import pycall but if i import in a controller
>> function i get the error
>>
>> def phone(a):
>> print "calling ",a
>> from pycall import CallFile, Call, Application
>> call = Call('SIP/robert')
>> action = Application('Playback', 'hello-world')
>> c = CallFile(call, action)
>> c.spool()
>> return 0
>>
>> *No module named pycall*
>>
>>
>> Help would be apreciated
>>
>> Thanks
>> António
>>
>  --
>
>
>
>

-- 





Re: [web2py] Re: we should support this in DAL

2012-11-19 Thread Simon Ashley
The part would would have interested us is potential to re factor live 
systems, particularly with changing tenancy requirements. 
Thinking that while the DAL, by necessity will have relational database 
tendencies and may never have full nosql capability, it would be 
interesting to explore areas the extended DAL could open.

On Monday, November 19, 2012 7:20:36 PM UTC+11, Vasile Ermicioi wrote:
>
> the main problem is that web2pys DAL is designed for relational databases, 
> and writing nosql adapaters will mean porting just a subset of relational 
> functionality, but you will not be able to take advantage of unstructured 
> data, because from web2py point of view it will look structured, just 
> stored on a nosql database
>
> so I think we need to start designing the functionality for a nosql 
> version of DAL and only after that to start implement it
>

-- 





[web2py] Dynamically generating forms from db data which will not be used to store the results in the db

2012-11-19 Thread Amber Doctor
I'm trying to determine the best way to code the following situation in 
web2py.

Currently I have a model that has this in it:

db.define_table('ingredient',
Field('ingredient_name', 'string', required=True),
Field('kind_ref', 'reference kind', required=True, 
requires=IS_IN_DB(db, 'kind.id','%(kind_name)s')),
Field('type_ref', 'reference ingredient_type', 
required=True, requires=IS_IN_DB(db, 'ingredient_type.id','%(type_name)s')),
Field('subtype_ref', 'reference ingredient_subtype', 
required=True, requires=IS_IN_DB(db, 
'ingredient_subtype.id','%(subtype_name)s')),
Field('brand_ref', 'reference ingredient_brand', 
required=True, requires=IS_IN_DB(db, 
'ingredient_brand.id','%(brand_name)s')),
Field('is_approved', 'boolean', default=True),
Field('for_match', 'boolean', default=True),
Field('ingredient_so', 'integer', default=50),
format='%(ingredient_name)s'
)

db.define_table('drink_recipe_ingredients',
Field('drink_recipe_ref', 'reference drink_recipe', 
requires=IS_IN_DB(db, 'drink_recipe.id','%(drink_recipe_name)s')),
Field('ingredient_ref', 'reference ingredient', 
requires=IS_IN_DB(db, 'ingredient.id','%(ingredient_name)s')),
Field('quantity'),
Field('unit_ref', 'reference unit', requires=IS_IN_DB(db, 
'unit.id','%(unit_of_measure)s')),
Field('is_approved', 'boolean', default=True),
Field('drink_recipe_ingredients_so', 'integer', default=50)
)


from a pseudo use case perspective what I want to do is:
1) back end grab 3 sets of data (one for kind, 1,2,3) kinda like:  alcohols 
= db((db.ingredient.kind_ref=='1') & (db.ingredient.for_match==True) & 
(db.ingredient.is_approved==True)).select()
2) front end display a check box that indicates that you are or are not 
including information from those three sets of information - "category 
selector"
3) display those three lists of items with check boxes next to each item in 
the list
4) let the user select the check boxes and submit
5) in the back end - use the "category selector" and the checked items in 
each category to create another query that pulls information from the 
drink_recipe_ingredients table

no data gathered is stored in the database.  more than one user can be 
executing this behavior at the same time.

Any advice on the best way to this would be great.

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Sebastian Cambeo
might it be, that "users.create_login_url(request.env.path_info)" in 
"check_credentials" needs some kind of file access?

Anyhow this request appears to trigger the error

-- 





Re: [web2py] Missing dumps() in rss2 contrib

2012-11-19 Thread Bruno Rocha
I guess it is solved in trunk. I had this problem, then I updated from
github and its gone.

Bruno Rocha
http://rochacbruno.com.br
mobile
 Em 19/11/2012 14:44, "Rene Dohmen"  escreveu:

> Hi All,
>
> i'm running web2py 2.2.1
> When I try to return a rss with the generic.rss view or when I try to
> follow example
> http://www.web2py.com/examples/simple_examples/rss_aggregator
>
> It serves a ticket with:
>
>
> 'module' object has no attribute 'dumps'
>
>
> The gluon/contrib/rss2 -> doesn't have a dumps method??
> Am I doing something wrong?
>
> Kind Regards Rene
>
> --
>
>
>
>

-- 





Re: [web2py] Re: request args

2012-11-19 Thread peter
Don't have this statement

 return response.stream(open('tuto1.pdf'))

Instead redirect to wherever you want to go next, or just have a plain old 
return and use your routine as a function.

Peter

On Monday, 19 November 2012 12:06:51 UTC, Paul Rykiel wrote:
>
> yes, I realize this ... I just don't want a screen to come up.
> The screen PDF displays with the first record. Can we supress? 
>
> On Mon, Nov 19, 2012 at 5:16 AM, peter 
> > wrote:
>
>> Paul I think you will find that you have created a file. The file 
>> tuto1.pdf will be in your web2py folder which is maybe why you are not 
>> seeing it.
>>
>> if you do
>>
>> pdf.output(name=request.folder+'/static/tuto1.pdf')
>>
>> It would put it in the static folder of your application.
>>
>> Peter
>>
>>
>> On Monday, 19 November 2012 02:30:14 UTC, Paul Rykiel wrote:
>>>
>>> Thank you Peter... i actually got it working, but I have a specific 
>>> question ... I have been just trying out the PDF creation and the following 
>>> example works great ... it is simple and I think it will suffice, here is 
>>> my question ... how do I get it to save to a director and not just display 
>>> the PDF on the screen? any help you can offer would be great. Regards,
>>>  
>>> from gluon.contrib.fpdf import FPDF
>>> def pdfexp():
>>> example = "this is an example"
>>> example2 = "this is example 2"
>>> pdf=FPDF()
>>> pdf.add_page()
>>> pdf.set_font('Arial','B',16)
>>> pdf.cell(40,10, example)
>>> pdf.add_page()
>>> pdf.set_font('Arial','B',16)
>>> pdf.cell(40,10, example2)
>>> pdf.output('tuto1.pdf','F')
>>> return response.stream(open('tuto1.**pdf'))
>>>
>>> On Sunday, November 18, 2012 3:39:44 AM UTC-6, peter wrote:
>>>
 Paul here is a reply to your pyfpdf question.

 I think the best way to use pyfpdf with web2py is not to install 
 pyfpdf, but to include it in your application. So download the source 
 file. 
 Put all the .py files in the modules folder of your application. Copy the 
 font folder into the modules folder of your app. Remember to restart 
 web2py 
 to allow the changes in the module folder to filter through. This works 
 for 
 me and I find pyfpdf pretty good. 

 Peter

 On Tuesday, 13 November 2012 23:28:59 UTC, Paul Rykiel wrote:
>
> Hi just learning WEB2py and I have a question:
>  
> why do i get an error on this code
>  This code errors out, but when I replace "tag_no" with 1 for 
> record id 1, it works, also the variable "tag_no" has a 1 as a value when 
> i 
> type in an argument 1 on the end of the URL *
>  
> def tag():
> tag_no = request.args(0) 
> Title = "For Sale"
>   *  Rows = db(db.bike.id==tag_no).select()   *
> for row in Rows:
>  serial = row.serial
>  make = row.make
>  model = row.model
>  size = row.size
>  color = row.color
>  style = row.style
>  date_of_receipt = row.date_of_receipt
>  repairs = row.repairs_done
>  price = row.price
> return locals()
>
  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: How to get register_next to move on to the desired URL

2012-11-19 Thread peter

# Instructions: Copy all of this into your db.py, and make the one change 
in layout.html

# Solution: how to have a user redirected to a page AFTER register
# in this example, the URL('user/profile') will be used.


# app name: AuthRedirect  <- just a NEW application, with no modication
# web2py Version 2.2.1 (2012-10-21 16:57:04) stable

# - - - - -
# in layout.html view, modify the line:
# {{='auth' in globals() and 
auth.navbar(mode="dropdown") or ''}}
# to
# {{='auth' in globals() and 
auth.navbar(mode="dropdown",referrer_actions=None) or ''}}
# this will cause the URL not to display
# 
http://127.0.0.1:8000/AuthRedirect/default/user/login?_next=/AuthRedirect/default/index
 
# but rather
# http://127.0.0.1:8000/AuthRedirect/default/user/


# - - - - -
# one line of CODE BELOW placed in : 

# /models/db.py - located BELOW the  setting under > ## configure auth 
policy lines

auth.settings.register_next = URL('user/profile') 

Peter

On Sunday, 18 November 2012 22:51:14 UTC, Daniele wrote:
>
> Hey guys, I would like to set register_next to move on to a URL upon 
> successful registration. However, it seems to be redirecting me to the 
> login page right now. I believe this is because I have 
>
> @auth.requires_login()
> def mypage:
>
> in the controller. How can I make it so that when a user registers, the 
> page automatically is redirected to a page I specify?
>
> Thanks!
>

-- 





[web2py] Missing dumps() in rss2 contrib

2012-11-19 Thread Rene Dohmen
Hi All,

i'm running web2py 2.2.1
When I try to return a rss with the generic.rss view or when I try to
follow example
http://www.web2py.com/examples/simple_examples/rss_aggregator

It serves a ticket with:

'module' object has no attribute 'dumps'


The gluon/contrib/rss2 -> doesn't have a dumps method??
Am I doing something wrong?

Kind Regards Rene

-- 





Re: [web2py] Ref: Lines and shapes

2012-11-19 Thread Bruno Rocha
Tks!

web2py has no api for this, in that case you should use JavaScript, html
and css.

You can generate this on web2py side, but in the end it will be the same.

Pyjamas, jquery or raphael should have functions or libs to design.

You can also look at Matplotlib.

Bruno Rocha
http://rochacbruno.com.br
mobile
 Em 19/11/2012 06:49, "Teddy Nyambe"  escreveu:

> Hi Bruno,
>
> cant seem to find content relating raphaeljs eventually finding what
> am looking for programmatically imaging with web2py.
>
> BTW congratulation on your selection on PSF.
>
> kind regards,
>
> Teddy
>
> On Mon, Nov 19, 2012 at 7:23 AM, Bruno Rocha 
> wrote:
> > You need HTML, JS and CSS.
> >
> > take a look in raphaeljs
> >
> > Bruno Rocha
> > http://rochacbruno.com.br
> > mobile
> >
> > Em 19/11/2012 02:32, "Teddy Nyambe"  escreveu:
> >>
> >> Hi,
> >>
> >> Does web2py support drawing of lines and shapes and inserting text
> inside
> >> drawn shapes? Thanx in advance.
> >>
> >> Teddy
> >>
> >> --
> >>
> >>
> >>
> >
> > --
> >
> >
> >
>
>
>
> --
>
> ...
> Teddy Lubasi Nyambe
> Opensource Zambia
> Lusaka, ZAMBIA
>
> Cell: +260 97 7760473
> website: http://www.opensource.org.zm
>
> ~/
> Human Knowledge belongs to the world! - AntiTrust
>
> Man is a tool-using animal. Without tools he is nothing, with tools he
> is all - Thomas Carlyle 1795-1881
>
> /~
>
> --
>
>
>
>

-- 





Re: [web2py] Re: Bug? Invalid url puts python into a tight loop - 100% CPU

2012-11-19 Thread jc
I have been thinking a little about this. Niphlod's suggestion solves the 
problem for me at the moment, but isn't there an enormous problem? It seems 
that any web2py installation can be taken down accidentally or maliciously 
just by somebody requesting an invalid argument string in the url of the 
form 'xxX' where the 'x's are valid characters and there are enough of 
them, and the 'X' is invalid? There must be a lot of vulnerable sites out 
there.

It seems to me there is one easy fix which is to just strip out invalid 
characters before the regex match. You will get collisions, but since the 
url is invalid anyway, who cares? Or the string could be urlencoded first 
so that the invalid characters become % encoded?


On Tuesday, November 13, 2012 7:33:26 PM UTC, Jonathan Lundell wrote:
>
> On 13 Nov 2012, at 11:20 AM, Niphlod > 
> wrote:
>
> I'm definitely not a regex master, but what's the *[=.]?* part required 
> for ?
>
>
> The idea (not mine, fwiw) is that you can have multiple strings of [\w@ 
> -]+ separated or ended (but not begun) with a single . or = (but not 
> multiple ones). My workaround would allow leading or multiple . or =. I 
> think we probably should anyway, since we should be assuming that args are 
> necessarily a file path, which seems to be what's going on there.
>
> It's trying to prevent stuff like foo/../../../bar.
>
>
> On Tuesday, November 13, 2012 7:00:32 PM UTC+1, Jonathan Lundell wrote:
>>
>> On 13 Nov 2012, at 9:04 AM, Niphlod  wrote:
>>
>> seems a problem with the default regex checking for args Let's wait 
>> for Jonathan
>>
>> >>> import re
>> >>> mymatch = re.compile(r'([\w@ -]+[=.]?)*$')
>> >>> mymatch.match('a')
>> <_sre.SRE_Match object at 0x02A61020>
>> >>> mymatch.match('A Lccc - Pddd GA Dee (  
>> A).pdf')
>>
>> endless loop of backtracing regex
>>
>>
>> I don't have a quick fix. The easy solutions involve re elements not 
>> available in Python re (or at least not until 3.1).
>>
>> A workaround would be to make the pattern a little more lenient: [\w@ 
>> -=.]+
>>
>> If we really want to exclude successive dots or equals, we could make a 
>> separate check for that.
>>
>
>
>
>
>

-- 





Re: [web2py] Re: Implementing tornado chat server with web2py

2012-11-19 Thread Ovidio Marinho
look is this http://vimeo.com/38972256



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




2012/11/19 dederocks 

> Regarding the error 426 mentionned, I don't know if you tried to use
> chromium instead of chrome. At least I has the 426 error in chromium, but
> NOT with chrome. Hope this helps.
>
> Le jeudi 19 janvier 2012 17:23:53 UTC+1, Phyo Arkar a écrit :
>>
>> Websocket is not ready , it is just a draft protocol. i wont recommend
>> any serious use on it.
>>
>> On Wed, Jan 18, 2012 at 6:57 AM, Abhishek Gupta 
>> wrote:
>>
>>> I implemented a similar solution, but the user keeps on getting
>>> disconnected from the tornado server. This happens frequently with chrome.
>>> Any guesses, so as why the user is being disconnected so often (in every
>>> 4-5 secs).
>>
>>
>>  --
>
>
>
>

-- 





Re: [web2py] Re: we should support this in DAL

2012-11-19 Thread Adnan Smajlovic
Hi Simon, i didn't go too far with DAL and mongo. Managed to get the grid,
but as mentioned before had a problem retrieving individual record
(document) for view and update. Then I included pymongo, and got needed
functionality outside of grid, but didn't have time then to continue
working on it.

Agreed with Vasile that it should be design properly, and then implemented
as a nosql version of DAL. Not sure how I could help, if not with coding,
then with testing at least?


On Sun, Nov 18, 2012 at 5:02 PM, Simon Ashley  wrote:

> What issues are you coming up against with Mongo/ nosql ports and DAL
> operations?
> Interested because we need to start investigating this.
>
>
> On Sunday, November 18, 2012 12:02:12 PM UTC+10, Adi wrote:
>>
>> Definitely would be nice to support NoSQL.
>>
>> I tried the existing DAL with MongoDB and grid worked fine to the point
>> of view/edit record. Due to different concepts (sql/nosql) if it's hard to
>> keep them in a same DAL, maybe there could be a separate layer for NoSQL.
>>
>> I would be glad to test lots in this area, since I'm trying to port 4-5M
>> records into MongoDB, and currently I use web2py with pymongo for that.
>>
>>
>> On Saturday, November 17, 2012 7:19:15 AM UTC-5, Massimo Di Pierro wrote:
>>>
>>> http://labs.codernity.com/**codernitydb/index.html
>>>
>>  --
>
>
>
>

-- 





[web2py] Re: error export represet

2012-11-19 Thread www.diazluis.com
example:

b50_periodo_academico.py:

db.define_table('periodo_academico',
Field('carrera',db.carrera),
Field('codigo', 'string', length=16), # 
Field('nombre', 'string', length=64, default='Carrera, Nombre del 
Periodo'), # odontologia 2013-2014
Field('fecha_ini', 'date'),
Field('fecha_fin', 'date'),
Field('sistema', 'string', length=1, default='1'),


#auditoria
Field('ip', 'string', length=64,  default=request.client, 
update=request.client, writable=False, readable=False),
Field('fecha', 'date',default=request.now, update=request.now, 
writable=False, readable=False),
Field('user_update', db.auth_user, default=id_user, update=id_user, 
writable=False, readable=False),

format = '%(nombre)s'
)

# requires
db.periodo_academico.codigo.requires = db.periodo_academico.nombre.requires 
= _requires_nombre
db.periodo_academico.sistema.requires = IS_IN_SET(_status, zero=None)

#represent
db.periodo_academico.sistema.represent = lambda v, row: mi_represent(v, 
 _status)




db_base_config.py:

_status = {
'1':'Cerrado',
'2':'Activo',
'3':'Uso interno',
}


def mi_represent(v, almacen, row=None):
mostrar = None
try:
mostrar = almacen[v]
except:
mostrar = '---'
return mostrar



El viernes, 16 de noviembre de 2012 17:45:23 UTC-4:30, Massimo Di Pierro 
escribió:
>
> some where you have a Field(...,represent=something)
>
> and something takes two arguments, not one. Can you show us the model?
>
> On Friday, 16 November 2012 08:51:32 UTC-6, www.diazluis.com wrote:
>>
>> {{
>> import cStringIO
>> stream=cStringIO.StringIO()
>> estudiante_arancel_rows.export_to_csv_file(ofile=stream, represent=True)
>> response.headers['Content-Type']='application/vnd.ms-excel'
>> response.headers['Content-Disposition'] =  "attachment; filename=%s" % 
>> 'data_sga.csv'
>> response.write(stream.getvalue(), escape=False)
>> }}
>>
>>
>> Traceback (most recent call last):
>>   File "/home/diazluis2007/web2py/gluon/restricted.py", line 212, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/diazluis2007/web2py/applications/sga/views/estudiante_arancel/exportar_excel.html",
>>  
>> line 3, in 
>> stream=cStringIO.StringIO()
>>   File "/home/diazluis2007/web2py/gluon/dal.py", line 9249, in 
>> export_to_csv_file
>> value = field.represent(value)
>> TypeError: () takes exactly 2 arguments (1 given)
>>
>>  web2py: 2.2.1
>>
>

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Niphlod
all the records ?
if you need to execurte your "test()" function you just need the browser to 
"go" to that page. Let's assume that in your controller you have

def index():
 grid = grid(db.testtable)
 grid[0][1][1].components = [
TAG.button('testbutton', _id="px-delete",_type="button",_href=URL(
'test'))
  ]

def test():
# delete all records of db.testtable
db(db.testtable.id>0).delete()
redirect(URL('index'))


Assuming that:
- you go to myapp/default/index and see the grid with the button (assuming 
the code fragment you posted works for adding a button, didn't test it).
- press that button
- the browser will go to the page myapp/default/test (the button was a 
normal link)
- web2py will delete the table
- and you'll be redirected back to your (now empty) grid.

Is it clear ? Is this what you want to achieve ?

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
I simply have to delete the records from the table, but problem what I am 
facing is : if the function would not be get called then how will I achieve 
this?

On Monday, 19 November 2012 19:31:53 UTC+5:30, Niphlod wrote:
>
> now you're the one that needs explaining it further :P
> I assume that just going to the "test" function and return back would not 
> be enough ? (i.e. a simple _href=URL('test') on that button)
>
> On Monday, November 19, 2012 2:56:36 PM UTC+1, Amit wrote:
>>
>> upon clicking the button , I need to make query to db and delete the 
>> records...
>>
>> On Monday, 19 November 2012 19:23:54 UTC+5:30, Niphlod wrote:
>>>
>>> the _onclick parameter is "translated" to just a plain onclick attribute 
>>> of the tag you're using.
>>>
>>> When you do in HTML mylink nothing will 
>>> happen. 
>>> an _onclick of "alert('clicked me')" will fire an alert box (language: 
>>> javascript).
>>>
>>> What do you need to do upon clicking that button ?
>>
>>

-- 





[web2py] Re: No module named xxx Ubuntu

2012-11-19 Thread Mandar Vaze
if pycall is under applications/myapp/modules, then try restarting web2py
When I created a new file under the modules folder, web2py couldn't 
import until it was restarted

See if it helps

-Mandar

On Thursday, November 15, 2012 5:38:27 PM UTC+5:30, Ramos wrote:
>
> Hello
> i have web2py running in Ubuntu 12.04
>
> i installed a module Pycall as root
>
> On the ubuntu console i can import pycall but if i import in a controller 
> function i get the error
>
> def phone(a):
> print "calling ",a
> from pycall import CallFile, Call, Application
> call = Call('SIP/robert')
> action = Application('Playback', 'hello-world')
> c = CallFile(call, action)
> c.spool()
> return 0
>
> *No module named pycall*
>
>
> Help would be apreciated
>
> Thanks
> António
>

-- 





Re: [web2py] Jquery function not triggered for fields in LOAD component

2012-11-19 Thread Richard Vézina
Thanks Niphlod,

It works! The only little glitch is that the calendar pop far from the
input field but I don't mine as long as it appears.

Richard

On Fri, Nov 16, 2012 at 5:14 PM, Niphlod  wrote:

> have you inspected where it goes on error ? My bet would be on the
> calendar setup ... seems that you're trying to bind a click on an element
> to trigger the "parent" to show the calendar. But the calendar is
> supposedly yet present on the input field. If so, why don't you just use
> live ?
> e.g.
>
> jQuery('.icon-calendar').on('click', function()
> {$(this).parent().prev().trigger("onclick");})
>
> PS: you are not using bootstrap features embedded in bootstrap.js, just
> some classes to add icon classes around.
>
>  --
>
>
>
>

-- 





[web2py] Re: "Premature end of script headers: wsgihandler.py" on usage of BytesIO()

2012-11-19 Thread Niphlod
google points to this 
http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions
the fact that on the development server all goes ok is a symptom that 
apache is the culprit.

On Monday, November 19, 2012 2:20:42 PM UTC+1, Yasir Saleem wrote:
>
> Hi all,
>
> I am generating graphs using "*cairo plot*" in web2py project. Here I am 
> using *BytesIO()* stream for generating graphs. Everything runs fine when 
> I run on localhost but when I deploy it on apache server and then run from 
> different machines OR from different browsers in same machine then the 
> server becomes halt and in apache error log, I found this error message:
> *Premature end of script headers: wsgihandler.py,*
>
> Furthermore, it occurs only when I use BytesIO() stream for generating 
> graphs. In all other cases, it run smoothly.
>
> Please guide me that how I should resolve this issue. Furthermore, please 
> also guide, if I can use any stream other *BytesIO()*
>

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Niphlod
now you're the one that needs explaining it further :P
I assume that just going to the "test" function and return back would not 
be enough ? (i.e. a simple _href=URL('test') on that button)

On Monday, November 19, 2012 2:56:36 PM UTC+1, Amit wrote:
>
> upon clicking the button , I need to make query to db and delete the 
> records...
>
> On Monday, 19 November 2012 19:23:54 UTC+5:30, Niphlod wrote:
>>
>> the _onclick parameter is "translated" to just a plain onclick attribute 
>> of the tag you're using.
>>
>> When you do in HTML mylink nothing will 
>> happen. 
>> an _onclick of "alert('clicked me')" will fire an alert box (language: 
>> javascript).
>>
>> What do you need to do upon clicking that button ?
>
>

-- 





[web2py] "Premature end of script headers: wsgihandler.py" on usage of BytesIO()

2012-11-19 Thread Yasir Saleem
Hi all,

I am generating graphs using "*cairo plot*" in web2py project. Here I am 
using *BytesIO()* stream for generating graphs. Everything runs fine when I 
run on localhost but when I deploy it on apache server and then run from 
different machines OR from different browsers in same machine then the 
server becomes halt and in apache error log, I found this error message:
*Premature end of script headers: wsgihandler.py,*

Furthermore, it occurs only when I use BytesIO() stream for generating 
graphs. In all other cases, it run smoothly.

Please guide me that how I should resolve this issue. Furthermore, please 
also guide, if I can use any stream other *BytesIO()*

-- 





[web2py] global name 'T' / 'auth' / 'request' is not defined, but i'm in a model file...

2012-11-19 Thread Cédric Mayer
Hello everyone!
I developped an application using web2py 1.99.xx some months ago, and I 
passed it to web2py 2.2.1 in order to be up to date :-) (And I prefer the 
new layout...) Thanks again for this beautiful version !

Nevertheless, I since encountered several strange problems 
(request.vars['not existing key"] does not throws a KeyError anymore ; Row 
does not inherit from dict ; a "tooltip" class is now defined by default 
for Bootstrap...) but none of which was very difficult to solve.

But today, I stubled on something too complicated unless I missed something.

Here is the trace I have, which explains everything :

Traceback (most recent call last):
  File 
"C:\Users\cedric\projets\LACT\eclipse\Lactw221\web2py\gluon\restricted.py", 
line 212, in restricted
exec ccode in environment
  File 
"C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/controllers/evaluation.py"
 , 
line 657, in 
  File "C:\Users\cedric\projets\LACT\eclipse\Lactw221\web2py\gluon\globals.py", 
line 188, in 
self._caller = lambda f: f()
  File "C:\Users\cedric\projets\LACT\eclipse\Lactw221\web2py\gluon\tools.py", 
line 2911, in f
return action(*a, **b)
  File 
"C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/controllers/evaluation.py"
 , 
line 189, in stop
_stop(userid)
  File 
"C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/controllers/evaluation.py"
 , 
line 248, in _stop
return mode.on_end()
  File 
"C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/models/a34_lact_running_modes.py"
 
,
 line 43, in on_end
session.flash = T('Serie finished! Thank you!')
NameError: global name 'T' is not defined


As you see, a34_running_modes.py is in the 'models' folder. But a function 
from it called from the controller doesn't know of 'T' which is global !
Previously I had the same error in some other functions with 'auth' 
(defined in a12_db.py, so still before) and 'request', which I solved by 
passing 'auth' or 'request' as function arguments (even if I find it not 
very nice...), as they are available in the controller function.

But if even T is not known, I cannot pass all usual global variables as 
arguments to every function present in 'models' folder.

Do I miss something ? Like a "what-to-check-if-you want-to-upgrade web2py" 
documentation ? (even if I thought web2py was fully backward compatible, 
this is why I choose it)

Thank you for your insights !

-- 





[web2py] Re: Extracting row id from url using request.args

2012-11-19 Thread Michael Hall
Hi Villas

I like the idea of using a var instead of args but I am still uncertain of 
how I get the ID of the current record I am viewing/editing in smartgrid.

Mike

On Monday, 19 November 2012 08:57:09 UTC, villas wrote:
>
> If you cannot control the order of args,  you could still look for an 
> int,  but that may not always be reliable.  I sometimes decide to use vars 
> instead.  Then you know exactly what you have:  your/url/here?id=1234
> Construction of the url is easy using the URL helper.
>
> On Friday, November 16, 2012 12:45:35 PM UTC, Mike H wrote:
>>
>> I am using smartgrid for the membership database I am building.
>>
>> I have 3 tables, contact (the members contact details and name), courses 
>> (any courses the member is doing with us) and membership (the users 
>> membership details).
>>
>> I am using conditionals to present customised view of the generated forms 
>> tables and records, basically a little dashboard that will sit above the 
>> contact/member/course details giving an overview of that contact. However I 
>> am struggling to extract the row id for the contact in order to pull up 
>> data for my dashboard.
>>
>> The following is the URL I get when viewing a contact with the id 11: 
>> 27.0.01:8000/MYDB/default/contact_manage/t_contact/t_membership.f_contact_id/11/view/t_membership/11
>>
>> On this particular url I can get the id using:
>> request.args(2)
>>
>> However the postion of the id is not the same on every page  for example 
>> when I view another contact (12) I get this URL:
>>
>> http://127.0.01:8000/ILSPA_DB2/default/contact_manage/t_contact/view/t_contact/12
>>
>> The argument with the position 2 is t_contact not 12.
>>
>> Is there some voodoo I can use to get the id of the entry in order to use 
>> it to pull up data from other tables?
>>
>> FYI I have included a snippet from the controller and corresponding view.
>>
>> Controller code:
>>
>> @auth.requires_login()
>> def contact_manage():
>> memberId = request.args(2)
>> form = SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses',
>> 't_membership','t_paypal'], onupdate=auth.archive, formname="Contact 
>> Manager")
>> return locals()
>>
>> View Code:
>>
>> {{extend 'layout.html'}}
>>
>> {{if 'view' in request.args:}}
>> Do something with {{=memberId}}
>> Manage Contact{{=form}}
>> {{else:}}
>> Manage Contact{{=form}}
>> {{pass}}
>>
>> Thanks in advance.
>>
>> Mike
>>
>

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
upon clicking the button , I need to make query to db and delete the 
records...

On Monday, 19 November 2012 19:23:54 UTC+5:30, Niphlod wrote:
>
> the _onclick parameter is "translated" to just a plain onclick attribute 
> of the tag you're using.
>
> When you do in HTML mylink nothing will 
> happen. 
> an _onclick of "alert('clicked me')" will fire an alert box (language: 
> javascript).
>
> What do you need to do upon clicking that button ?

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Niphlod
the _onclick parameter is "translated" to just a plain onclick attribute of 
the tag you're using.

When you do in HTML mylink nothing will 
happen. 
an _onclick of "alert('clicked me')" will fire an alert box (language: 
javascript).

What do you need to do upon clicking that button ?

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
Could you elaborate more on this with some example code?

On Monday, 19 November 2012 19:13:58 UTC+5:30, Niphlod wrote:
>
> _onclick expects a javascript fragment to be executed. 
>
> On Monday, November 19, 2012 2:40:24 PM UTC+1, Amit wrote:
>>
>> Hi,
>> I have added one custom button after *Search* and *Clear* buttons of 
>> SQLFORM.grid but unable to associate the action onto it, onclick is not 
>> getting called.Please see below the code:
>>
>> grid = SQLFORM.grid(db.test_table,deletable=True)
>> grid[0][1][1].components = [
>>   TAG.button('testbutton', _id="px-delete",_type="button",_onclick=
>> 'test')
>> ]
>>
>> def test():
>> print 'test called'
>>
>> "testbutton" is getting added perfectly but when i click on it , it 
>> doesn't call test() function, how to achieve it? Please do help me.
>>
>>

-- 





[web2py] Re: Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Niphlod
_onclick expects a javascript fragment to be executed. 

On Monday, November 19, 2012 2:40:24 PM UTC+1, Amit wrote:
>
> Hi,
> I have added one custom button after *Search* and *Clear* buttons of 
> SQLFORM.grid but unable to associate the action onto it, onclick is not 
> getting called.Please see below the code:
>
> grid = SQLFORM.grid(db.test_table,deletable=True)
> grid[0][1][1].components = [
>   TAG.button('testbutton', _id="px-delete",_type="button",_onclick=
> 'test')
> ]
>
> def test():
> print 'test called'
>
> "testbutton" is getting added perfectly but when i click on it , it 
> doesn't call test() function, how to achieve it? Please do help me.
>
>

-- 





[web2py] Unable to call the onclick on my custom button on SQLFORM.grid

2012-11-19 Thread Amit
Hi,
I have added one custom button after *Search* and *Clear* buttons of 
SQLFORM.grid but unable to associate the action onto it, onclick is not 
getting called.Please see below the code:

grid = SQLFORM.grid(db.test_table,deletable=True)
grid[0][1][1].components = [
  TAG.button('testbutton', _id="px-delete",_type="button",_onclick=
'test')
]

def test():
print 'test called'

"testbutton" is getting added perfectly but when i click on it , it doesn't 
call test() function, how to achieve it? Please do help me.

-- 





[web2py] Re: can't open my database Administration anymore

2012-11-19 Thread Massimo Di Pierro
Somewhere you are redefining db to be a string. Try print db at the top od 
your controller.

On Monday, 19 November 2012 04:44:39 UTC-6, BlueShadow wrote:
>
> Hi,
> I got a big problem I can't use the databaseadministration of my website 
> anymore. I cecked previous versions and two versions ago it works without a 
> problem. The funny thing is the db.py files are exactly the same I changed 
> nothing in the database mainly in views but I would hate to work from my 
> old version and change it all over again to find the error.
> Thats the error message:
>
> Traceback (most recent call last):
>   File "F:\Website\web2py\gluon\restricted.py", line 212, in restricted
> exec ccode in environment
>   File "F:/Website/web2py/applications/1101/views/appadmin.html" 
> , line 
> 450, in 
> AttributeError: 'str' object has no attribute 'Article'
>
> Arows=db(db.Article).select(orderby=~db.Article.Submitted, limitby=(0,3))
>
>
> but I didn't change anything in appadmin ristricted or the database. And 
> the line in question is ordering something by a date not a str. Is there 
> any quick fix?
>

-- 





[web2py] Re: password verification

2012-11-19 Thread Massimo Di Pierro
Check there are using the same version of python. Some older pyhton 
versions have a buggy hashlib and results in incorrect hashing.

On Monday, 19 November 2012 03:22:59 UTC-6, Manuele wrote:
>
> Hi! 
> I'd like to ask how a password is verified? I've noticed that cloning my 
> project in a parallel one with a different name that use the same db 
> connection (to postgres) the same user cannot be recognized from the new 
> application. What's the right way to do this operation? 
>
> Thanks a lot 
>
>  M. 
>

-- 





[web2py] Re: admin interface + GAE

2012-11-19 Thread Massimo Di Pierro
Strange. this is a gae error.

On Monday, 19 November 2012 03:16:46 UTC-6, Sebastian Cambeo wrote:
>
> What comes as a surprise to me is that the admin interface is working in 
> the GAE SDK emulation...
>
> The error log:
>
> In FILE: 
> /base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py
>
> Traceback (most recent call last):
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/restricted.py",
>  line 212, in restricted
> exec ccode in environment
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py",
>  line 37, in 
> if gluon.fileutils.check_credentials(request):
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/fileutils.py",
>  line 345, in check_credentials
> % users.create_login_url(request.env.path_info)
>   File 
> "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/users.py",
>  line 256, in create_login_url
> raise NotAllowedError
> NotAllowedError
>
>

-- 





[web2py] Re: GAE + Cloud Sql just does not work

2012-11-19 Thread Massimo Di Pierro
http://code.google.com/p/web2py/issues/detail?id=1176&thanks=1176&ts=1353330181


will fix tonight

On Monday, 19 November 2012 03:11:24 UTC-6, Sebastian Cambeo wrote:
>
> Thank you! I checked out trunk and now it is working unless I call the 
> truncate method on any table:
>
> Traceback (most recent call last):
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363276531332237989/gluon/restricted.py",
>  line 212, in restricted
> exec ccode in environment
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363276531332237989/applications/Cambeo/models/db.py",
>  line 105, in 
> db.auth_user.truncate()
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363276531332237989/gluon/dal.py", line 
> 7923, in truncate
> return self._db._adapter.truncate(self, mode)
>   File 
> "/base/data/home/apps/s~cambeoserver/1.363276531332237989/gluon/dal.py", line 
> 1371, in truncate
> logfile.close()
> AttributeError: DatabaseStoredFile instance has no attribute 'close'
>
>

-- 





[web2py] Re: manual file upload fails when storing file in database - field is NULL

2012-11-19 Thread Massimo Di Pierro
Please do.

On Sunday, 18 November 2012 23:21:16 UTC-6, Cliff Kachinske wrote:
>
> Aha.
>
> I could not find the call to stream.read in the pdf manual.
>
> Manual uploads appears to be removed from the on-line manual.  Is that 
> intentional?  If not I could write up a patch for the book in the next day 
> or so.
>
> By the way, the code allows uploads to be attached to any table in the 
> application.  I can put it on github with a bsd license if you think anyone 
> would be interested.
>
> Cliff Kachinske
>
> On Friday, November 16, 2012 5:20:07 PM UTC-5, Massimo Di Pierro wrote:
>>
>> Yes:
>>
>> att_id = db2.attachments.insert(
>> attachment = db2.attachments.attachment.store(...),
>> filename = fname,
>> Description = 
>> r.attachments.attachment_brief_description,
>> )
>> needs
>>
>> att_id = db2.attachments.insert(
>> attachment = db2.attachments.attachment.store(...),
>> payload = stream.read(),
>> filename = fname,
>> Description = 
>> r.attachments.attachment_brief_description,
>> )
>>
>> On Friday, 16 November 2012 09:18:47 UTC-6, Cliff Kachinske wrote:
>>>
>>> The title describes the problem.
>>>
>>> Any suggestions as to what I might do?  Would it be simpler if I just 
>>> uploaded to a directory?  I'm archiving for auditability, so I suppose 
>>> there would still be a way to get at earlier versions of uploaded files.
>>>
>>> Here is the model:
>>>
>>> db.define_table('attachments',
>>> Field('attachment', 'upload', uploadfield='payload'),
>>> Field('filename', length=512),
>>> Field('Description', 'text'),
>>> Field('payload', 'blob'),
>>> migrate=init_migrate,
>>> )
>>> Common fields are auth.signature and a field called "tenant_link", which 
>>> is how I implemented the request_tenant functionality before Massimo 
>>> announced it.
>>>
>>> Here is the controller code:
>>>for r in rows:
>>> ...
>>> myfile = mypath + r.attachments.file_name + '.' + 
>>> r.attachments.file_ext
>>> try:
>>> stream = open(myfile, 'rb')
>>> except IOError:
>>> no_finds.append(DIV('unable to find {}'.format(myfile)))
>>> continue
>>> else:
>>> ok.append(DIV('found {}.{}, aka {}'.format(
>>> r.attachments.file_name, r.attachments.file_ext, fname
>>> )))
>>> att_id = db2.attachments.insert(
>>> attachment = db2.attachments.attachment.store(
>>> stream, '{}.{}'.format(
>>> r.attachments.file_name, 
>>> r.attachments.file_ext
>>> )
>>> ),
>>> filename = fname,
>>> Description = 
>>> r.attachments.attachment_brief_description,
>>> )
>>>
>>> The insert is successful except the payload field is never populated. 
>>>  Here is a snippet  of the results from this postgres query, "SELECT id, 
>>> filename, octet_length(payload) from attachments;"
>>>
>>>   9 | apt-get-output.txt 
>>>  |10772
>>>   10 | a_h_hits.txt 
>>>|24164
>>>   11 | a_h_hits.txt 
>>>|24164
>>>   12 | greg-free-bizcard 
>>>   |   215288
>>>   27 | Tank Thickness ML.doc 
>>>   | 
>>>   28 | Tank Thickness ML.doc(1) 
>>>| 
>>>   29 | A short short file   
>>>| 
>>>   30 | hello.txt 
>>>   |
>>>
>>> Records 9, 10 and 11 were uploaded while testing the interface. Records 
>>> 12 and up were created using the above script. 
>>>
>>>

-- 





[web2py] Changing Validators for SQLFORM on same table

2012-11-19 Thread Mike S
Hi all,

I'm wondering if anyone knows what the best way is to change validators on 
a table's input form.  In my program, if the record is initially added, I 
only need the validators to check a subset of fields (IS_NOT_EMPTY, etc.), 
but in another state I need to check them all.

My first attempt involved dynamically recreating the form initially with 
SQLFORM.factory and later using normal SQLFORM, using different validators 
in the 'requires' parameter of each Field.  This was causing problems with 
the workflow because in the later state there was no way to edit the record 
and come back to it later because every field had to be filled in, which is 
not practical.

So I changed it to specify the 'requires' validators on the DAL object (db) 
like this:

db.table_name.field_name.requires = [ IS_NOT_EMPTY(), ... ]
form = SQLFORM(...)
form.process()

This works great, but it feels like the wrong thing to do, since it is 
changing the validators for the table, not the form.  It works fine across 
sessions, but the validators do persist to the next form for that table in 
the same session, which is fine as long as I remember to set them properly 
before every SQLFORM.  

Is there a better way to do this?  Is there perhaps some way to reach into 
the SQLFORM and pull out the fields and their validators?  I went 
spelunking in that code but came up empty-handed.  It's pretty dense stuff.

Thanks,
-Mike

-- 





[web2py] Re: Extracting row id from url using request.args

2012-11-19 Thread Michael Hall
Hi Villas

I like the idea of getting the ID from a var instead of args, however I am 
still not sure how to go about getting the ID of the current record I am 
viewing/editing in smartgrid.

Forgive my noobishness.

M

On Monday, 19 November 2012 08:57:09 UTC, villas wrote:
>
> If you cannot control the order of args,  you could still look for an 
> int,  but that may not always be reliable.  I sometimes decide to use vars 
> instead.  Then you know exactly what you have:  your/url/here?id=1234
> Construction of the url is easy using the URL helper.
>
> On Friday, November 16, 2012 12:45:35 PM UTC, Mike H wrote:
>>
>> I am using smartgrid for the membership database I am building.
>>
>> I have 3 tables, contact (the members contact details and name), courses 
>> (any courses the member is doing with us) and membership (the users 
>> membership details).
>>
>> I am using conditionals to present customised view of the generated forms 
>> tables and records, basically a little dashboard that will sit above the 
>> contact/member/course details giving an overview of that contact. However I 
>> am struggling to extract the row id for the contact in order to pull up 
>> data for my dashboard.
>>
>> The following is the URL I get when viewing a contact with the id 11: 
>> 27.0.01:8000/MYDB/default/contact_manage/t_contact/t_membership.f_contact_id/11/view/t_membership/11
>>
>> On this particular url I can get the id using:
>> request.args(2)
>>
>> However the postion of the id is not the same on every page  for example 
>> when I view another contact (12) I get this URL:
>>
>> http://127.0.01:8000/ILSPA_DB2/default/contact_manage/t_contact/view/t_contact/12
>>
>> The argument with the position 2 is t_contact not 12.
>>
>> Is there some voodoo I can use to get the id of the entry in order to use 
>> it to pull up data from other tables?
>>
>> FYI I have included a snippet from the controller and corresponding view.
>>
>> Controller code:
>>
>> @auth.requires_login()
>> def contact_manage():
>> memberId = request.args(2)
>> form = SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses',
>> 't_membership','t_paypal'], onupdate=auth.archive, formname="Contact 
>> Manager")
>> return locals()
>>
>> View Code:
>>
>> {{extend 'layout.html'}}
>>
>> {{if 'view' in request.args:}}
>> Do something with {{=memberId}}
>> Manage Contact{{=form}}
>> {{else:}}
>> Manage Contact{{=form}}
>> {{pass}}
>>
>> Thanks in advance.
>>
>> Mike
>>
>

-- 





[web2py] Re: Janrain Alternative: SimpleAuth (And its totally free)

2012-11-19 Thread Taryn Cooksey
Looks pretty good, but using an opensource means maintenance and upgrading 
issue, so I'd rather prefer a SaaS solution. After doing little research, I 
found a good alternative LoginRadius (www.loginradius.com). Did anyone try 
it? Would love to hear some feedback.

-- 





Re: [web2py] Unique constraint/index on multiple fields?

2012-11-19 Thread Dragan Matic
I'm using postgres too, that will be the way to go, tnx

On Monday, November 19, 2012 7:57:32 AM UTC+1, Johann Spies wrote:
>
> On 16 November 2012 15:59, Dragan Matic 
> > wrote:
>
>> It has been asked before but I haven't seen any definitive answer. Is 
>> there a way to enforce unique constraint or index on multiple fields or if 
>> not are there any plans to implement it? It can come handy in checking data 
>> integrity and lots of databases support it. 
>>
>>
> I use the database backend (PostgreSQL in my case) to enforce that.  
> Web2py will then receive an error message from the backend when the 
> constraint has been violated.  
>
> You can do a try...  except   to cach the exception. 
>
> Regards
> Johann
>
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 





Re: [web2py] Re: request args

2012-11-19 Thread Paul Rykiel
yes, I realize this ... I just don't want a screen to come up.
The screen PDF displays with the first record. Can we supress?

On Mon, Nov 19, 2012 at 5:16 AM, peter  wrote:

> Paul I think you will find that you have created a file. The file
> tuto1.pdf will be in your web2py folder which is maybe why you are not
> seeing it.
>
> if you do
>
> pdf.output(name=request.folder+'/static/tuto1.pdf')
>
> It would put it in the static folder of your application.
>
> Peter
>
>
> On Monday, 19 November 2012 02:30:14 UTC, Paul Rykiel wrote:
>>
>> Thank you Peter... i actually got it working, but I have a specific
>> question ... I have been just trying out the PDF creation and the following
>> example works great ... it is simple and I think it will suffice, here is
>> my question ... how do I get it to save to a director and not just display
>> the PDF on the screen? any help you can offer would be great. Regards,
>>
>> from gluon.contrib.fpdf import FPDF
>> def pdfexp():
>> example = "this is an example"
>> example2 = "this is example 2"
>> pdf=FPDF()
>> pdf.add_page()
>> pdf.set_font('Arial','B',16)
>> pdf.cell(40,10, example)
>> pdf.add_page()
>> pdf.set_font('Arial','B',16)
>> pdf.cell(40,10, example2)
>> pdf.output('tuto1.pdf','F')
>> return response.stream(open('tuto1.**pdf'))
>>
>> On Sunday, November 18, 2012 3:39:44 AM UTC-6, peter wrote:
>>
>>> Paul here is a reply to your pyfpdf question.
>>>
>>> I think the best way to use pyfpdf with web2py is not to install pyfpdf,
>>> but to include it in your application. So download the source file. Put all
>>> the .py files in the modules folder of your application. Copy the font
>>> folder into the modules folder of your app. Remember to restart web2py to
>>> allow the changes in the module folder to filter through. This works for me
>>> and I find pyfpdf pretty good.
>>>
>>> Peter
>>>
>>> On Tuesday, 13 November 2012 23:28:59 UTC, Paul Rykiel wrote:

 Hi just learning WEB2py and I have a question:

 why do i get an error on this code
  This code errors out, but when I replace "tag_no" with 1 for
 record id 1, it works, also the variable "tag_no" has a 1 as a value when i
 type in an argument 1 on the end of the URL *

 def tag():
 tag_no = request.args(0)
 Title = "For Sale"
   *  Rows = db(db.bike.id==tag_no).select()   *
 for row in Rows:
  serial = row.serial
  make = row.make
  model = row.model
  size = row.size
  color = row.color
  style = row.style
  date_of_receipt = row.date_of_receipt
  repairs = row.repairs_done
  price = row.price
 return locals()

>>>  --
>
>
>
>

-- 





Re: [web2py] Re: Choosing the PDF file's name with appreport PISA

2012-11-19 Thread David Sorrentino
Mandar,

Thank you very much. I downloaded the version 0.1.x and it perfectly works.
I didn't think that wiki page could have pointed to an old version of the
plugin.

I wish you a wondeful day,
David


On 19 November 2012 11:28, Mandar Vaze  wrote:

> David,
> When I downloaded the 0.1.x version from Downloads section, the
> response_filename param works. Hope this helps.
>
> Lucas,
> https://github.com/lucasdavila/web2py-appreport/wiki page points to older
> w2p file, which is an year old.
> May be you should update the documentation to point to 0.1.x version.
>
> -Mandar
>
>
> On Monday, November 19, 2012 2:24:07 PM UTC+5:30, Mandar Vaze wrote:
>>
>> Same here. I downloaded the w2p on Nov 12th - so I think I have the
>> latest version. But the filename seems to be ignored.
>> I'm using web2py 2.0.9
>>
>> On Monday, November 12, 2012 1:26:53 PM UTC+5:30, David Sorrentino wrote:
>>>
>>> Hello everybody! :)
>>>
>>> I am using appreport with the PISA engine in order to export a view to a
>>> PDF file and I would like to choose the name of the PDF file generated.
>>> The view is the following one:
>>> results = dict(success=True)
>>> html = response.render('default/**results.html', results)
>>> return plugin_appreport.REPORTPISA(ht**ml = html, response_filename =
>>> 'change_my_name.pdf')
>>>
>>> As you can see, I used the parameter *response_filename* for setting a
>>> custom name, but it doesn't seem to work.
>>> Any suggestions?
>>>
>>> Cheers,
>>> David
>>>
>>  --
>
>
>
>

-- 





[web2py] Re: smartgrid + oncreate not working

2012-11-19 Thread vivek
Hi , 

Did you find a workaround for this? 

On Thursday, March 1, 2012 9:53:50 PM UTC+4, Tito Garrido wrote:
>
> Hi Folks,
>
> I am trying to execute the function adicionar_estoque after I create a new 
> "entrada_produto" entry... am I doing anything wrong? Nothing is happening 
> even when I put a non existent function on the oncreate statement.
>
> I am using web2py stable.
>
> def adicionar_estoque(form):
> print 'executou oncreate'
> entrada_produto_id = form.vars.id
> row = db(db.entrada_produto.id==entrada_produto_id).select().first()
> produto=db(db.produto.id==row.produto).select().first()
> produto.em_estoque=produto.em_estoque+row.quantidade
> 
> session.flash = 'Estoque atualizado'
> return
>
> def entradas():
> db.entrada_produto.entrada.writable = False
> 
> form=SQLFORM.smartgrid(db.entrada,linked_tables=['entrada_produto'],searchable=
>  
> dict(entrada=True, entrada_produto=False),deletable= dict(entrada=False, 
> entrada_produto=True),editable= dict(entrada=False, 
> entrada_produto=False),create= dict(entrada=False, 
> entrada_produto=True),maxtextlength=dict(entrada=50, entrada_produto=50), 
> details=dict(entrada=False, 
> entrada_produto=False),oncreate=dict(entrada=None,entrada_produto=lambda 
> form: adicionar_estoque(form)))
> return dict(form=form)
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 





[web2py] Re: request args

2012-11-19 Thread peter
Paul I think you will find that you have created a file. The file tuto1.pdf 
will be in your web2py folder which is maybe why you are not seeing it.

if you do

pdf.output(name=request.folder+'/static/tuto1.pdf')

It would put it in the static folder of your application.

Peter

On Monday, 19 November 2012 02:30:14 UTC, Paul Rykiel wrote:
>
> Thank you Peter... i actually got it working, but I have a specific 
> question ... I have been just trying out the PDF creation and the following 
> example works great ... it is simple and I think it will suffice, here is 
> my question ... how do I get it to save to a director and not just display 
> the PDF on the screen? any help you can offer would be great. Regards,
>  
> from gluon.contrib.fpdf import FPDF
> def pdfexp():
> example = "this is an example"
> example2 = "this is example 2"
> pdf=FPDF()
> pdf.add_page()
> pdf.set_font('Arial','B',16)
> pdf.cell(40,10, example)
> pdf.add_page()
> pdf.set_font('Arial','B',16)
> pdf.cell(40,10, example2)
> pdf.output('tuto1.pdf','F')
> return response.stream(open('tuto1.pdf'))
>
> On Sunday, November 18, 2012 3:39:44 AM UTC-6, peter wrote:
>
>> Paul here is a reply to your pyfpdf question.
>>
>> I think the best way to use pyfpdf with web2py is not to install pyfpdf, 
>> but to include it in your application. So download the source file. Put all 
>> the .py files in the modules folder of your application. Copy the font 
>> folder into the modules folder of your app. Remember to restart web2py to 
>> allow the changes in the module folder to filter through. This works for me 
>> and I find pyfpdf pretty good. 
>>
>> Peter
>>
>> On Tuesday, 13 November 2012 23:28:59 UTC, Paul Rykiel wrote:
>>>
>>> Hi just learning WEB2py and I have a question:
>>>  
>>> why do i get an error on this code
>>>  This code errors out, but when I replace "tag_no" with 1 for 
>>> record id 1, it works, also the variable "tag_no" has a 1 as a value when i 
>>> type in an argument 1 on the end of the URL *
>>>  
>>> def tag():
>>> tag_no = request.args(0) 
>>> Title = "For Sale"
>>>   *  Rows = db(db.bike.id==tag_no).select()   *
>>> for row in Rows:
>>>  serial = row.serial
>>>  make = row.make
>>>  model = row.model
>>>  size = row.size
>>>  color = row.color
>>>  style = row.style
>>>  date_of_receipt = row.date_of_receipt
>>>  repairs = row.repairs_done
>>>  price = row.price
>>> return locals()
>>>
>>

-- 





[web2py] can't open my database Administration anymore

2012-11-19 Thread BlueShadow
Hi,
I got a big problem I can't use the databaseadministration of my website 
anymore. I cecked previous versions and two versions ago it works without a 
problem. The funny thing is the db.py files are exactly the same I changed 
nothing in the database mainly in views but I would hate to work from my 
old version and change it all over again to find the error.
Thats the error message:

Traceback (most recent call last):
  File "F:\Website\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "F:/Website/web2py/applications/1101/views/appadmin.html" 
, line 450, 
in 
AttributeError: 'str' object has no attribute 'Article'

Arows=db(db.Article).select(orderby=~db.Article.Submitted, limitby=(0,3))


but I didn't change anything in appadmin ristricted or the database. And 
the line in question is ordering something by a date not a str. Is there 
any quick fix?

-- 





[web2py] Re: Choosing the PDF file's name with appreport PISA

2012-11-19 Thread Mandar Vaze
David, 
When I downloaded the 0.1.x version from Downloads section, the 
response_filename param works. Hope this helps.

Lucas,
https://github.com/lucasdavila/web2py-appreport/wiki page points to older 
w2p file, which is an year old.
May be you should update the documentation to point to 0.1.x version. 

-Mandar

On Monday, November 19, 2012 2:24:07 PM UTC+5:30, Mandar Vaze wrote:
>
> Same here. I downloaded the w2p on Nov 12th - so I think I have the latest 
> version. But the filename seems to be ignored.
> I'm using web2py 2.0.9
>
> On Monday, November 12, 2012 1:26:53 PM UTC+5:30, David Sorrentino wrote:
>>
>> Hello everybody! :)
>>
>> I am using appreport with the PISA engine in order to export a view to a 
>> PDF file and I would like to choose the name of the PDF file generated.
>> The view is the following one:
>> results = dict(success=True)
>> html = response.render('default/results.html', results)
>> return plugin_appreport.REPORTPISA(html = html, response_filename = 
>> 'change_my_name.pdf')
>>
>> As you can see, I used the parameter *response_filename* for setting a 
>> custom name, but it doesn't seem to work.
>> Any suggestions? 
>>
>> Cheers,
>> David
>>
>

-- 





Re: [web2py] Re: Implementing tornado chat server with web2py

2012-11-19 Thread dederocks
Regarding the error 426 mentionned, I don't know if you tried to use 
chromium instead of chrome. At least I has the 426 error in chromium, but 
NOT with chrome. Hope this helps.

Le jeudi 19 janvier 2012 17:23:53 UTC+1, Phyo Arkar a écrit :
>
> Websocket is not ready , it is just a draft protocol. i wont recommend any 
> serious use on it.
>
> On Wed, Jan 18, 2012 at 6:57 AM, Abhishek Gupta 
> 
> > wrote:
>
>> I implemented a similar solution, but the user keeps on getting 
>> disconnected from the tornado server. This happens frequently with chrome. 
>> Any guesses, so as why the user is being disconnected so often (in every 
>> 4-5 secs).
>
>
>

-- 





[web2py] password verification

2012-11-19 Thread Manuele Pesenti

Hi!
I'd like to ask how a password is verified? I've noticed that cloning my 
project in a parallel one with a different name that use the same db 
connection (to postgres) the same user cannot be recognized from the new 
application. What's the right way to do this operation?


Thanks a lot

M.

--





[web2py] Re: admin interface + GAE

2012-11-19 Thread Sebastian Cambeo
What comes as a surprise to me is that the admin interface is working in 
the GAE SDK emulation...

The error log:

In FILE: 
/base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/restricted.py", 
line 212, in restricted
exec ccode in environment
  File 
"/base/data/home/apps/s~cambeoserver/1.363277968286640588/applications/admin/models/access.py",
 line 37, in 
if gluon.fileutils.check_credentials(request):
  File 
"/base/data/home/apps/s~cambeoserver/1.363277968286640588/gluon/fileutils.py", 
line 345, in check_credentials
% users.create_login_url(request.env.path_info)
  File 
"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/users.py", 
line 256, in create_login_url
raise NotAllowedError
NotAllowedError

-- 





[web2py] Re: GAE + Cloud Sql just does not work

2012-11-19 Thread Sebastian Cambeo
Thank you! I checked out trunk and now it is working unless I call the 
truncate method on any table:

Traceback (most recent call last):
  File 
"/base/data/home/apps/s~cambeoserver/1.363276531332237989/gluon/restricted.py", 
line 212, in restricted
exec ccode in environment
  File 
"/base/data/home/apps/s~cambeoserver/1.363276531332237989/applications/Cambeo/models/db.py",
 line 105, in 
db.auth_user.truncate()
  File "/base/data/home/apps/s~cambeoserver/1.363276531332237989/gluon/dal.py", 
line 7923, in truncate
return self._db._adapter.truncate(self, mode)
  File "/base/data/home/apps/s~cambeoserver/1.363276531332237989/gluon/dal.py", 
line 1371, in truncate
logfile.close()
AttributeError: DatabaseStoredFile instance has no attribute 'close'

-- 





[web2py] Re: Extracting row id from url using request.args

2012-11-19 Thread villas
If you cannot control the order of args,  you could still look for an int,  
but that may not always be reliable.  I sometimes decide to use vars 
instead.  Then you know exactly what you have:  your/url/here?id=1234
Construction of the url is easy using the URL helper.

On Friday, November 16, 2012 12:45:35 PM UTC, Mike H wrote:
>
> I am using smartgrid for the membership database I am building.
>
> I have 3 tables, contact (the members contact details and name), courses 
> (any courses the member is doing with us) and membership (the users 
> membership details).
>
> I am using conditionals to present customised view of the generated forms 
> tables and records, basically a little dashboard that will sit above the 
> contact/member/course details giving an overview of that contact. However I 
> am struggling to extract the row id for the contact in order to pull up 
> data for my dashboard.
>
> The following is the URL I get when viewing a contact with the id 11: 
> 27.0.01:8000/MYDB/default/contact_manage/t_contact/t_membership.f_contact_id/11/view/t_membership/11
>
> On this particular url I can get the id using:
> request.args(2)
>
> However the postion of the id is not the same on every page  for example 
> when I view another contact (12) I get this URL:
>
> http://127.0.01:8000/ILSPA_DB2/default/contact_manage/t_contact/view/t_contact/12
>
> The argument with the position 2 is t_contact not 12.
>
> Is there some voodoo I can use to get the id of the entry in order to use 
> it to pull up data from other tables?
>
> FYI I have included a snippet from the controller and corresponding view.
>
> Controller code:
>
> @auth.requires_login()
> def contact_manage():
> memberId = request.args(2)
> form = SQLFORM.smartgrid(db.t_contact,linked_tables=['t_courses',
> 't_membership','t_paypal'], onupdate=auth.archive, formname="Contact 
> Manager")
> return locals()
>
> View Code:
>
> {{extend 'layout.html'}}
>
> {{if 'view' in request.args:}}
> Do something with {{=memberId}}
> Manage Contact{{=form}}
> {{else:}}
> Manage Contact{{=form}}
> {{pass}}
>
> Thanks in advance.
>
> Mike
>

-- 





[web2py] Re: Choosing the PDF file's name with appreport PISA

2012-11-19 Thread Mandar Vaze
Same here. I downloaded the w2p on Nov 12th - so I think I have the latest 
version. But the filename seems to be ignored.
I'm using web2py 2.0.9

On Monday, November 12, 2012 1:26:53 PM UTC+5:30, David Sorrentino wrote:
>
> Hello everybody! :)
>
> I am using appreport with the PISA engine in order to export a view to a 
> PDF file and I would like to choose the name of the PDF file generated.
> The view is the following one:
> results = dict(success=True)
> html = response.render('default/results.html', results)
> return plugin_appreport.REPORTPISA(html = html, response_filename = 
> 'change_my_name.pdf')
>
> As you can see, I used the parameter *response_filename* for setting a 
> custom name, but it doesn't seem to work.
> Any suggestions? 
>
> Cheers,
> David
>

-- 





Re: [web2py] Ref: Lines and shapes

2012-11-19 Thread Teddy Nyambe
Hi Bruno,

cant seem to find content relating raphaeljs eventually finding what
am looking for programmatically imaging with web2py.

BTW congratulation on your selection on PSF.

kind regards,

Teddy

On Mon, Nov 19, 2012 at 7:23 AM, Bruno Rocha  wrote:
> You need HTML, JS and CSS.
>
> take a look in raphaeljs
>
> Bruno Rocha
> http://rochacbruno.com.br
> mobile
>
> Em 19/11/2012 02:32, "Teddy Nyambe"  escreveu:
>>
>> Hi,
>>
>> Does web2py support drawing of lines and shapes and inserting text inside
>> drawn shapes? Thanx in advance.
>>
>> Teddy
>>
>> --
>>
>>
>>
>
> --
>
>
>



-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he
is all - Thomas Carlyle 1795-1881

/~

-- 





Re: [web2py] Re: we should support this in DAL

2012-11-19 Thread Vasile Ermicioi
the main problem is that web2pys DAL is designed for relational databases,
and writing nosql adapaters will mean porting just a subset of relational
functionality, but you will not be able to take advantage of unstructured
data, because from web2py point of view it will look structured, just
stored on a nosql database

so I think we need to start designing the functionality for a nosql version
of DAL and only after that to start implement it

--