[web2py] Re: Combine IS_IN_DB and IS_NOT_IN_DB

2015-04-25 Thread Niphlod
You should read the section on database validators  
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Database-validators

you can either use the _and argument of IS_IN_DB, but more easily for 
everybody, e.g. there's not even a chance they can select an ip that is 
used yet, you can just pass a set instead of the whole table to IS_IN_DB...

db(~db.ipaddress.id.belongs(db(db.server.id0)._select(db.server.ipaddress_id)))

On Saturday, April 25, 2015 at 5:28:16 PM UTC+2, kecajk...@gmail.com wrote:

 Hi Guys, 

 I have simple database:

 db.define_table('ipaddress',
Field('ip', unique=True, length=200),
Field('subnet', length=200),
format = '%(ip)s')

 db.define_table('server',
Field('servername', length=200),
Field('port', length=200),
Field('ipaddress_id', 'reference ipaddress'))

 I have few records in ipaddress table and not would like to add some 
 validators. 
 When adding record to server table i would like to check if ipaddress_id 
 exist in ipaddress table AND if it hasn't been used before in server table.
 That can be done by doing:

 db.server.ipaddress_id.requires = IS_IN_DB(db,db.ipaddress.id, '%(ip)s') 
 ,IS_NOT_IN_DB(db,db.server.ipaddress_id, '%(ip)s')]

 But in that case Filed server.ipaddress_id is not a dropdown menu and it's 
 not presented as %(ip)s. I would like to have dropdown to choose IP 
 available in ipaddress table, but just the one which hasn't been used 
 before. Any tips? 

 Thanks, 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: database chema recommendations needed

2015-04-25 Thread Richard Vézina
Yes, but it is in python... I would use it as a starting point and
transform it into a web app... But I don't know what you are doing and what
you already have... But what you were talking about seems to me as a pretty
big undertake for a single man!! (but again you maybe not alone).

Richard

On Wed, Apr 22, 2015 at 10:24 PM, John jhnpl...@gmail.com wrote:

 Gramps is a desktop program for building a family tree. We have a web
 based version that we're fine with although I'd like to tie it into the
 actual site sometime for joint login purposes. This other part of the site
 is the individual transcriptions of old records. The data you would
 reference/cite as sources for facts in doing research for building a family
 tree.
 Upon further thought, places (State, County, CityTown) be best in it's own
 table so they each only get stored once.

 On Tuesday, April 21, 2015 at 10:05:32 AM UTC-5, John wrote:

 New to programming and web2py. Been dabbling in web design for a while,
 building sites with wordpress, plugging things in. My first real project
 will be a site/app for my sister. Genealogical resources. Lots of records
 that will need to be added via csv and also via forms. Will also need to be
 displayed in sortable grid/table format and will need advanced search
 capabilities. These records will be things like births, deaths, marriages
 etc and would have anywhere from 10-20 fields for things like; surname |
 given name(s) | DOB | State | County | City/Town | Father surname | father
 given name | mother surname | mother given name | source.
 On the site, people would most likely browse by clicking a State, then
 the County and then Birth records at which point they would see the
 sortable grid/table with all birth records for that County, State.
 Else they would go to an advanced search page where they would choose the
 record type from a drop down, State from a drop down which would then
 populate a drop down for Counties of the chosen State. A choice for all
 States/Counties would be nice. Names, they would type in. DOB could be
 typed in as well though it would be nice if they could choose a date or
 date range. Some records may only have a partial date like maybe just the
 year.
 Each record type will have all the same fields of course so it only makes
 sense to have a table for each. There will be approx 20-30 different record
 types. I thought about individual tables for each record type for each
 state but that would be 51 tables(50 States plus DC) times however many
 record types there ends up being so 1000-1500 tables. Seems like too many.
 I'm in no rush and realize I have a lot of work to do and a lot to learn.
 At some point this site will hopefully become a community based site so
 membership and permissions will be needed. A forum would be nice but I
 haven't seen anything regarding that in the documentation yet. But first
 and foremost is the data records. I've read that each application gets it's
 own database so I'm thinking my first/main app would be *Records* with
 db tables for births, deaths, marriages etc. Am I correct in thinking that
 a table for each record type would be best and to not break it down by
 State but rather make State a field/column? Then again, when/if we end up
 with lots of records, that would be a lot of rows considering the number of
 births in the USA over a period of a few centuries.

  --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to the Google Groups
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: web2py update app admin doesn't work anymore

2015-04-25 Thread Kevin Bethke
thanks it worked perfectly

On Sat, Apr 25, 2015 at 6:18 PM, 黄祥 steve.van.chris...@gmail.com wrote:

 what version did you use right now?
 if i'm not wrong in the newest version got the pydal modules separate.
 please download and unzip from web2py website.

 ref:
 http://web2py.com/books/default/chapter/29/14/other-recipes#Upgrading
 http://web2py.com/init/default/download

 best regards,
 stifan

 --
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/Nze8LILg94M/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Caching Architecture Question

2015-04-25 Thread Mark Graves
Hey everyone, 

Question on cacheing  app architecture.

I have some selects I would like to cache for speedup, specifically in 
redis, but on a more abstract level, I have a question.

I have modularized most of my functions so I can efficiently iterate the 
application, and can unit test effectively.

In production, I'd like to have the selects cached for speed, but I don't 
want to pass in a cache object for every possible unit test.

Instead, I'd like to have global access to the cache, and turn it on and 
off with a global variable for testing.

I understand cache is a global variable with access to the web2py 
environment.

Can anyone forsee any problems with implementation of cacheing within a 
module that is NOT specifically passed in from the web2py environment, but 
rather imported externally? (I understand this is a hard question to 
answer, but I'm more just looking for : You're an idiot you completely 
forgot X).

Thank you all in advance.

Looking forward to seeing you at web2pycon2015!

-Mark

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: database chema recommendations needed

2015-04-25 Thread Mark Graves
Hey John,

Welcome to the community.

I'm not sure I understand your requirements exactly, but here is my 
thoughts on a schema:

For the initial MVP, I usually like to keep the amount of tables to a 
minimum, then as I figure out the common queries I can separate them out 
into multiple tables.

For an app such as yours, I would use validators and autocomplete, to 
ensure State, County, City/Town are the same:

Also, if ALL the fields are the same, and the only difference is the record 
type, why not add that as a different field?

IE:
VALID_RECORD_TYPES = ['Birth Certificate','Death Certificate']

db.define_table('genealogical_records',
 Field('location_state','string'),
 Field('location_county','string'),
 Field('location_city_town','string'),
 Field('record_type','string',requires=IS_IN_SET(VALID_RECORD_TYPES)),
 Field('attribute_1','type')).

As the database grows, you could change VALID_RECORD_TYPES to receive a 
function that is a select if you want it more dynamic:

db.define_table('valid_record_types',
 Field('label','string'),
 Field('input_attributes','list_string'))


def get_valid_record_types():
return [(row.id,row.label) for row in db(db.valid_record_types).select
()]

VALID_RECORD_TYPES = get_valid_record_types()

Also, you'll notice I put in the input attributes:

I find a common design pattern I use is:

fields = []
fields.append(db.table.field)

form =SQLFORM(*fields)


With this pattern in place, you could forseeably store the data fields you 
want to create for the form in the table for each record type

or you can do this in a module and import a list of fields you want to edit 
for each record type.

You can use groupby to get records grouped by city, state, etc.

Sorry if I'm chiming in and dont understand the requirements fully.

Obviously in the first part, you could obviously make those location fields 
references to a database table, but then you have a more complex join 
operation for every update and select.

-Mark


On Saturday, April 25, 2015 at 10:28:10 AM UTC-5, John wrote:

 Gramps is a desktop program for building a family tree. We have a web 
 based version that we're fine with although I'd like to tie it into the 
 actual site sometime for joint login purposes. This other part of the site 
 is the individual transcriptions of old records. The data you would 
 reference/cite as sources for facts in doing research for building a family 
 tree. 
 Upon further thought, places (State, County, CityTown) be best in it's own 
 table so they each only get stored once. 

 On Tuesday, April 21, 2015 at 10:05:32 AM UTC-5, John wrote:

 New to programming and web2py. Been dabbling in web design for a while, 
 building sites with wordpress, plugging things in. My first real project 
 will be a site/app for my sister. Genealogical resources. Lots of records 
 that will need to be added via csv and also via forms. Will also need to be 
 displayed in sortable grid/table format and will need advanced search 
 capabilities. These records will be things like births, deaths, marriages 
 etc and would have anywhere from 10-20 fields for things like; surname | 
 given name(s) | DOB | State | County | City/Town | Father surname | father 
 given name | mother surname | mother given name | source.
 On the site, people would most likely browse by clicking a State, then 
 the County and then Birth records at which point they would see the 
 sortable grid/table with all birth records for that County, State. 
 Else they would go to an advanced search page where they would choose the 
 record type from a drop down, State from a drop down which would then 
 populate a drop down for Counties of the chosen State. A choice for all 
 States/Counties would be nice. Names, they would type in. DOB could be 
 typed in as well though it would be nice if they could choose a date or 
 date range. Some records may only have a partial date like maybe just the 
 year. 
 Each record type will have all the same fields of course so it only makes 
 sense to have a table for each. There will be approx 20-30 different record 
 types. I thought about individual tables for each record type for each 
 state but that would be 51 tables(50 States plus DC) times however many 
 record types there ends up being so 1000-1500 tables. Seems like too many. 
 I'm in no rush and realize I have a lot of work to do and a lot to learn. 
 At some point this site will hopefully become a community based site so 
 membership and permissions will be needed. A forum would be nice but I 
 haven't seen anything regarding that in the documentation yet. But first 
 and foremost is the data records. I've read that each application gets it's 
 own database so I'm thinking my first/main app would be *Records* with 
 db tables for births, deaths, marriages etc. Am I correct in thinking that 
 a table for each record type would be best and to not break it down by 
 State but rather make State a field/column? Then 

[web2py] Re: database chema recommendations needed

2015-04-25 Thread Mark Graves
One more thing, if you are worried about the speed, you can always cache 
the results in memory.

On Tuesday, April 21, 2015 at 10:05:32 AM UTC-5, John wrote:

 New to programming and web2py. Been dabbling in web design for a while, 
 building sites with wordpress, plugging things in. My first real project 
 will be a site/app for my sister. Genealogical resources. Lots of records 
 that will need to be added via csv and also via forms. Will also need to be 
 displayed in sortable grid/table format and will need advanced search 
 capabilities. These records will be things like births, deaths, marriages 
 etc and would have anywhere from 10-20 fields for things like; surname | 
 given name(s) | DOB | State | County | City/Town | Father surname | father 
 given name | mother surname | mother given name | source.
 On the site, people would most likely browse by clicking a State, then the 
 County and then Birth records at which point they would see the sortable 
 grid/table with all birth records for that County, State. 
 Else they would go to an advanced search page where they would choose the 
 record type from a drop down, State from a drop down which would then 
 populate a drop down for Counties of the chosen State. A choice for all 
 States/Counties would be nice. Names, they would type in. DOB could be 
 typed in as well though it would be nice if they could choose a date or 
 date range. Some records may only have a partial date like maybe just the 
 year. 
 Each record type will have all the same fields of course so it only makes 
 sense to have a table for each. There will be approx 20-30 different record 
 types. I thought about individual tables for each record type for each 
 state but that would be 51 tables(50 States plus DC) times however many 
 record types there ends up being so 1000-1500 tables. Seems like too many. 
 I'm in no rush and realize I have a lot of work to do and a lot to learn. 
 At some point this site will hopefully become a community based site so 
 membership and permissions will be needed. A forum would be nice but I 
 haven't seen anything regarding that in the documentation yet. But first 
 and foremost is the data records. I've read that each application gets it's 
 own database so I'm thinking my first/main app would be *Records* with db 
 tables for births, deaths, marriages etc. Am I correct in thinking that a 
 table for each record type would be best and to not break it down by State 
 but rather make State a field/column? Then again, when/if we end up with 
 lots of records, that would be a lot of rows considering the number of 
 births in the USA over a period of a few centuries. 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] duplicate session when using ajax callback in component

2015-04-25 Thread 黄祥
hi,

is it possible to use ajax callback to update session value in component?
the same code on ajax callback is work fine when not in component 
(originally take from web2py appliance (estore)
i've tested it and ended with duplicate session during ajax callback to 
update session value in component :
*steps :*
1. choose dvd id = 2 with quantity 2 in sqlform.factory and submitted it
2. update the quantity into 1 in the checkout component

*result checked session value using response.toolbar()*
purchase:
2:
1
2:
2

*code*
*controllers/test.py*
session.purchase = session.purchase or {}
session_purchase = session.purchase
def test():
return dict()
def purchase_detail_callback():
id = int(request.vars.id)
if request.vars.action == 'remove':
del session.purchase[id]
redirect(request.env.http_web2py_component_location, client_side = True)
if request.vars.action == 'adjust_total_price':
quantity = int(request.vars['quantity_%s' % id])
price = int(request.vars.price)
*session.purchase[id] = quantity*
total_price = quantity * price
total_qty = 0
grand_total = 0
for calculation_id, calculation_quantity in session_purchase.items():
dvd = db.dvd(calculation_id)
calculation_total_price = calculation_quantity * dvd.acquisition_price
total_qty += calculation_quantity
grand_total += calculation_total_price
return jQuery('#total_price_%s').html(%s); jQuery('#total_qty').html(%s); 
jQuery('#grand_total').html(%s); % (id, total_price, total_qty, 
grand_total)

*views/test/test.html*
{{extend 'layout.html'}}
{{=LOAD('test', 'purchase_cart.load', ajax = True, vars = 
{'reload_div':'map'} ) }}
{{=LOAD('test', 'purchase_checkout.load', ajax = True, target = 'map') }}

*views/test/purchase_checkout.load*
{{total_qty = 0 }}
{{grand_total = 0 }}
table class=table table-condensed table-hover
tr
th{{=T('DVD') }}/th
th{{=T('Price') }}/th
th{{=T('Quantity') }}/th
th{{=T('Total Price') }}/th
th{{=T('Action') }}/td
/tr
{{for id, qty in order.items():}}
{{p = db.dvd(id) }}
{{total_price = qty * p.acquisition_price}}
{{total_qty += qty}}
{{grand_total += total_price}}
tr
td{{=SPAN(p.title) }}/td
td{{=SPAN('Rp. %s' % format(p.acquisition_price, ,d) ) }}/td
td
form
span class=col-xs-3
input name={{='quantity_%s' % p.id}} value={{=qty}} 
class=form-control
onkeyup=ajax('{{=URL('purchase_detail_callback', vars = dict(id = p.id, 
action = 'adjust_total_price', 
price = p.acquisition_price) ) }}', ['{{='quantity_%s' % p.id}}'], ':eval' 
) /
/span
/form
/td
tdRp. {{=SPAN('%s' % format(total_price, ,d), _id = 'total_price_%s' % 
p.id) }}/td
td
{{=SPAN(A(I(_class='glyphicon glyphicon-remove-sign'), 
callback=URL('purchase_detail_callback', vars=dict(id=p.id, 
action='remove') ), 
delete='tr', _title='Remove from Order') ) }}
/td
/tr
{{pass}}
tr
td/td
td{{=B(T('Grand Total') ) }}/td
td{{=SPAN('%s' % format(total_qty, ,d), _id = 'total_qty') }}/td
tdRp. {{=SPAN('%s' % format(grand_total, ,d), _id = 'grand_total') 
}}/td
td/td
/tr
/table

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Richard Vézina
I don't know what you are doing... As far as I can see the only thing you
have to do is to is that you call the script with as argument a valid
web2py db connection string...

a database dump is what is say you dump your db into a file... But I don't
think this script work like that, I thought it could work over a file, but
it seems to work against a web2py live db connection string...

Richard

On Sat, Apr 25, 2015 at 2:21 AM, Ron Chatterjee achatterjee...@gmail.com
wrote:

 Thanks for all the help Richard. I tried to work around the code
 extract_mysql_models.py (attached is the code). Basically, I installed
 XAMP/WAMP and in the phpmyadmin I have the sql database. I am running this
 code but it fails in line #74:

  p = subprocess.Popen(['mysqldump','--user=%s' % username,'--password=%s'
 % password,'--skip-add-drop-table','--no-data',
 database_name,table_name[0]], stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)

 sql_create_stmnt, stderr = p.communicate()


 I don't know what a mysql dump is. Wondering if the above two lines can be
 written like,


 cat_str = 'SELECT *From' +   + table_name[0]

 get_table = cursor.execute(cat_str)

 sql_create_stmnt = cursor.fetchall()


 And then go on with if 'CREATE' in sql_create_stmnt:


 Anyway, I am attaching the script if it make it makes it any clear.







 On Wednesday, April 22, 2015 at 12:44:08 PM UTC-7, Richard wrote:

 The version in the thread seems not have been included in web2py...

 Try the one in gluon/scripts/

 Richard

 On Wed, Apr 22, 2015 at 3:41 PM, Richard Vézina ml.richa...@gmail.com
 wrote:

 This regex : regex = re.compile('(.*?):(.*?)@(.*)')

 Seems to parse the below command line call!!

 Richard

 On Wed, Apr 22, 2015 at 3:39 PM, Richard Vézina ml.richa...@gmail.com
 wrote:


 https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py

 Ok, it is not working exactly how I thought it was... Do you have
 myslqldump install?

 Do you use Linux or Windows...

 what if you do

 python extract_mysql_models.py username:password@data_basename

 On Wed, Apr 22, 2015 at 3:28 PM, Ron Chatterjee achatte...@gmail.com
 wrote:

 I used this version (the first one) and change to MySQLdb.

 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 It gives me an error:

 Basically,

 This worked

 db = MySQLdb.connect(host = 'localhost',user ='root',passwd = '',db =
 'name_of_my_database')

 But this didn't.

 extract_mysql_models.py --user 'root' --password '' --host '127.0.0.1'
 --database 'name_of_my_database' --dalname 'wikidb' --colcomments
 --singlemigrate  mywiki.py

 Note, my password is empty.

 The error I get is simply that it can't connect to the server. So, I
 am going through the code now.







 On Wednesday, April 22, 2015 at 2:49:41 PM UTC-4, Richard wrote:

 What do you exactly get out of extract_mysql_models.py applied over
 an SQL dump of the schema (only no data inserts)?

 Richard

 On Wed, Apr 22, 2015 at 2:29 PM, Ron Chatterjee achatte...@gmail.com
  wrote:

 Sorry, wasn't clear. Basically want to create a DAL (db.py) file
 from an existing site that I locally hosted (wAMP) which is php front 
 end
 mysql backend. I exported out of my WAMP (phpmysqladmin) the tables and
 fields in SQL language. Then I tried to make DAL out of it. As you
 explained, thats not possible, Now I will try to take a stab at working
 with extract_mysql_models.py but it will probably will require some
 updates. If nothing works, I can use the MYSQL workbench to connect to 
 the
 server to draw me the schema and then write the DAL from that. Hope it
 clear things up now. My bad.



 On Wednesday, April 22, 2015 at 2:04:49 PM UTC-4, Richard wrote:

 Hello Ron,

 The more this thread goes the less I understand what you are trying
 to acheive... Do you want to translate a SQLite DB into a web2py 
 model? or
 MySQL DB? If you do have a MySQL server instance your connection string
 seems correct... But then you have to define the table you want to 
 access
 in this table or you only have DB connection active which give you 
 notting
 because the DAL don't know the DB structure...

 Richard

 On Wed, Apr 22, 2015 at 1:30 PM, Ron Chatterjee 
 achatte...@gmail.com wrote:

 This is what I was looking for.


 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 But homehow the code didn't work for me even when I followed the
 example like it says. So, I am creating a stand alone version that 
 works
 with MySQLdb.






 On Tuesday, April 21, 2015 at 4:58:52 PM UTC-4, Ron Chatterjee
 wrote:

 I have sqlite browser. I am guessing its the same like SQlite
 Manager where someone can import, export csv or sql file. I don't 
 have
 password in that database and work externally to the python

 *I guess one possibility will be:*

 import MySQLdb

 import sys

 try:

 db = MySQLdb.connect(host = 'localhost',user 

[web2py] Re: Capture XML response into string for further parsing with ElementTree

2015-04-25 Thread Niphlod
you have fromstring() for parsing the xml. just fetch it with, e.g. urllib2 
and load it with fromstring(). 

On Saturday, April 25, 2015 at 5:28:15 PM UTC+2, NeoToren wrote:

 Amazon Payments responds to a website with XML.
 Amazon doesn't send back an XML to my site - it just displays XML - at the 
 same URL my website sent a well formed, hashed and signed message.
 I need to parse the Amazon XML response into meaningful variables for 
 moving forward with the purchasing workflow.

 ElementTree can parse XML if fed with a file or a string.
 As far as I know ElementTree cannot read directly from an htttp address.
 Thus I need scrape the XML from the screen / that URL into a string to 
 feed ElementTree.

 How can I capture the XML into a string for further parsing
 ... or better still...
 Any magic to capture AND parse from a URL in a short and sweet way ?

 Thanks


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: LOAD() problem: Yes, I am bungling the world's smallest web2py app.

2015-04-25 Thread Tom Campbell
Thanks, Dmitry--some questions.

   1. What does will take no view mean for the showtasks() method?
   2. Why are .load extensions not recommended? There seems to be some 
   history on the list but I don't understand the issues.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: LOAD() problem: Yes, I am bungling the world's smallest web2py app.

2015-04-25 Thread Anthony
On Saturday, April 25, 2015 at 3:24:38 PM UTC-4, Tom Campbell wrote:

 Thanks, Dmitry--some questions.

1. What does will take no view mean for the showtasks() method?

 If you return a string or HTML helper object (which includes the grid), 
web2py will not look for/execute a view but will simply return the string 
or serialized helper directly, so there is no need for a view.


1. Why are .load extensions not recommended? There seems to be some 
history on the list but I don't understand the issues.

 The reason you might want to use a .load extension (or any alternative to 
the default .html) is in case the same action gets called as a standard 
HTML page as well as an Ajax component that gets loaded within a page -- 
that way you can have two different views (in the later case, you would 
typically not extend the layout.html view). The issue to consider is that 
when using the URL() function without specifying an extension, the 
extension of the current action is propagated, so uses of URL() within a 
.load action will have a .load URL, which you may or may not want (if you 
don't want the .load extension to propagate, you can simply set 
extension=False).

Anthony 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to set a condition with @auth.requires_login in Web2py

2015-04-25 Thread Anthony
Did this solution http://stackoverflow.com/a/29799597/440323 not work for 
you?

On Saturday, April 25, 2015 at 11:28:10 AM UTC-4, Christophe Meessen wrote:

 In my web2py web app, the controller function def index(): has the 
 decorator @auth.requires_login(). 

 For development and testing purpose I comment out this decorator. But I 
 often forget to uncomment it before committing the code. 

 I would like to change this decorator into something that would test if a 
 file is present (i.e. skipLogin) and if not to require login. I can then 
 add the skipLogin file in my .gitignore file and don't need to worry about 
 commenting and uncommenting the decorator line. 

 I suppose it should be something like @auth.requires(lambda: xxx) but I 
 have no idea what xxx should be. 



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Pydal ilike search inside a list of strings?

2015-04-25 Thread Massimo Di Pierro
db.tablename.fieldname.contains('whatever')

On Saturday, 25 April 2015 10:28:10 UTC-5, Tom Stratton wrote:

 Hi -

 I'm struggling to find a way to do an ilike style search within a list 
 of strings field in the db.

 For example, my field may contain ['Donald Duck', 'Minnie Mouse']

 I'd like that record returned when I am searching for '%mouse%'

 Maybe I need to cast the list to a string but this is just part of a 
 larger query and I'm hoping for a simpler, built in, solution.

 Thanks

 Tom

 PS - what does it take to get posting permissions? I feel like I would 
 participate more if my answers didn't get help overnight ;-)


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Ron Chatterjee
I got the code to run half way. I am saying, if we can bypass 
subprocess.Popen by:

cat_str = 'SELECT *From' +   + table_name[0]

get_table = cursor.execute(cat_str)

sql_create_stmnt = cursor.fetchall()


I may not need to have mysqldump or anything. I just don't know what 
subprocess.Popen does that we can't do with cursor.



On Saturday, April 25, 2015 at 7:57:56 PM UTC-7, Richard wrote:

 I never try it... I may try it for you, but not now, I am working late 
 tonight to push a new app version in production :(

 From the script doc :

 This plugin needs:mysqlmysqldumpinstalled and globally available.Under 
 Windows you will probably need to add the mysql executable directory to the 
 PATH variable,you will also need to modify mysql to mysql.exe and 
 mysqldump to mysqldump.exe below.Just guessing here :)Access your tables 
 with:legacy_db(legacy_db.mytable.id0).select()If the script crashes this 
 is might be due to that fact that the data_type_map dictionary below is 
 incomplete.Please complete it, improve it and continue.


 1) Do you have mysqldump installed??  
 https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
 2) Is it globally available (You talk about some LAMP setup so I guess you 
 are under windows in a virtual LAMP stack?? if so, this has to be check)
 3) Under windows? ... (same thing goes here...)
 4) Are you able to create a dummy app define a connection string and 
 define one of your model (one table of your mysql db) and then do a simple 
 db().select(db.yourTableName.ALL)??
 5) If the answer to 4 is yes I guess your are neer to make it works if the 
 precedent point are cover...

 Richard





 On Sat, Apr 25, 2015 at 10:41 PM, Ron Chatterjee achatte...@gmail.com 
 javascript: wrote:

 I very simple question. Have you tried? Does the script works for you? 
 Because it didn't work for me. Idk what you don't understand that I am 
 doing. Its all the same code. someone can just step through it and figure 
 out that its failing on subprocess.Popen. Idk why its so hard to 
 understand. Specially someone as good as you. And I mean it the good way:-).



 On Saturday, April 25, 2015 at 6:40:14 PM UTC-7, Richard wrote:

 I don't know what you are doing... As far as I can see the only thing 
 you have to do is to is that you call the script with as argument a valid 
 web2py db connection string...

 a database dump is what is say you dump your db into a file... But I 
 don't think this script work like that, I thought it could work over a 
 file, but it seems to work against a web2py live db connection string...

 Richard

 On Sat, Apr 25, 2015 at 2:21 AM, Ron Chatterjee achatte...@gmail.com 
 wrote:

 Thanks for all the help Richard. I tried to work around the code 
 extract_mysql_models.py (attached is the code). Basically, I installed 
 XAMP/WAMP and in the phpmyadmin I have the sql database. I am running this 
 code but it fails in line #74:

  p = subprocess.Popen(['mysqldump','--user=%s' % 
 username,'--password=%s' % password,'--skip-add-drop-table','--no-data', 
 database_name,table_name[0]], stdin=subprocess.PIPE, 
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)

 sql_create_stmnt, stderr = p.communicate()


 I don't know what a mysql dump is. Wondering if the above two lines can 
 be written like,


 cat_str = 'SELECT *From' +   + table_name[0]

 get_table = cursor.execute(cat_str)

 sql_create_stmnt = cursor.fetchall()


 And then go on with if 'CREATE' in sql_create_stmnt:


 Anyway, I am attaching the script if it make it makes it any clear.







 On Wednesday, April 22, 2015 at 12:44:08 PM UTC-7, Richard wrote:

 The version in the thread seems not have been included in web2py...

 Try the one in gluon/scripts/

 Richard

 On Wed, Apr 22, 2015 at 3:41 PM, Richard Vézina ml.richa...@gmail.com
  wrote:

 This regex : regex = re.compile('(.*?):(.*?)@(.*)')

 Seems to parse the below command line call!!

 Richard

 On Wed, Apr 22, 2015 at 3:39 PM, Richard Vézina 
 ml.richa...@gmail.com wrote:


 https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py

 Ok, it is not working exactly how I thought it was... Do you have 
 myslqldump install?

 Do you use Linux or Windows...

 what if you do

 python extract_mysql_models.py username:password@data_basename

 On Wed, Apr 22, 2015 at 3:28 PM, Ron Chatterjee 
 achatte...@gmail.com wrote:

 I used this version (the first one) and change to MySQLdb.

 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 It gives me an error:

 Basically, 

 This worked

 db = MySQLdb.connect(host = 'localhost',user ='root',passwd = '',db 
 = 'name_of_my_database')

 But this didn't.

 extract_mysql_models.py --user 'root' --password '' --host 
 '127.0.0.1' --database 'name_of_my_database' --dalname 'wikidb' 
 --colcomments --singlemigrate  mywiki.py

 Note, my password is empty.

 The error I get is simply that it can't connect to the server. So, 
 I am going through the 

Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Richard Vézina
I never try it... I may try it for you, but not now, I am working late
tonight to push a new app version in production :(

From the script doc :

This plugin needs:mysqlmysqldumpinstalled and globally available.Under
Windows you will probably need to add the mysql executable directory to the
PATH variable,you will also need to modify mysql to mysql.exe and mysqldump
to mysqldump.exe below.Just guessing here :)Access your tables with:
legacy_db(legacy_db.mytable.id0).select()If the script crashes this is
might be due to that fact that the data_type_map dictionary below is
incomplete.Please complete it, improve it and continue.


1) Do you have mysqldump installed??
https://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
2) Is it globally available (You talk about some LAMP setup so I guess you
are under windows in a virtual LAMP stack?? if so, this has to be check)
3) Under windows? ... (same thing goes here...)
4) Are you able to create a dummy app define a connection string and define
one of your model (one table of your mysql db) and then do a simple
db().select(db.yourTableName.ALL)??
5) If the answer to 4 is yes I guess your are neer to make it works if the
precedent point are cover...

Richard





On Sat, Apr 25, 2015 at 10:41 PM, Ron Chatterjee achatterjee...@gmail.com
wrote:

 I very simple question. Have you tried? Does the script works for you?
 Because it didn't work for me. Idk what you don't understand that I am
 doing. Its all the same code. someone can just step through it and figure
 out that its failing on subprocess.Popen. Idk why its so hard to
 understand. Specially someone as good as you. And I mean it the good way:-).



 On Saturday, April 25, 2015 at 6:40:14 PM UTC-7, Richard wrote:

 I don't know what you are doing... As far as I can see the only thing you
 have to do is to is that you call the script with as argument a valid
 web2py db connection string...

 a database dump is what is say you dump your db into a file... But I
 don't think this script work like that, I thought it could work over a
 file, but it seems to work against a web2py live db connection string...

 Richard

 On Sat, Apr 25, 2015 at 2:21 AM, Ron Chatterjee achatte...@gmail.com
 wrote:

 Thanks for all the help Richard. I tried to work around the code
 extract_mysql_models.py (attached is the code). Basically, I installed
 XAMP/WAMP and in the phpmyadmin I have the sql database. I am running this
 code but it fails in line #74:

  p = subprocess.Popen(['mysqldump','--user=%s' %
 username,'--password=%s' % password,'--skip-add-drop-table','--no-data',
 database_name,table_name[0]], stdin=subprocess.PIPE,
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)

 sql_create_stmnt, stderr = p.communicate()


 I don't know what a mysql dump is. Wondering if the above two lines can
 be written like,


 cat_str = 'SELECT *From' +   + table_name[0]

 get_table = cursor.execute(cat_str)

 sql_create_stmnt = cursor.fetchall()


 And then go on with if 'CREATE' in sql_create_stmnt:


 Anyway, I am attaching the script if it make it makes it any clear.







 On Wednesday, April 22, 2015 at 12:44:08 PM UTC-7, Richard wrote:

 The version in the thread seems not have been included in web2py...

 Try the one in gluon/scripts/

 Richard

 On Wed, Apr 22, 2015 at 3:41 PM, Richard Vézina ml.richa...@gmail.com
 wrote:

 This regex : regex = re.compile('(.*?):(.*?)@(.*)')

 Seems to parse the below command line call!!

 Richard

 On Wed, Apr 22, 2015 at 3:39 PM, Richard Vézina ml.richa...@gmail.com
  wrote:


 https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py

 Ok, it is not working exactly how I thought it was... Do you have
 myslqldump install?

 Do you use Linux or Windows...

 what if you do

 python extract_mysql_models.py username:password@data_basename

 On Wed, Apr 22, 2015 at 3:28 PM, Ron Chatterjee achatte...@gmail.com
  wrote:

 I used this version (the first one) and change to MySQLdb.

 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 It gives me an error:

 Basically,

 This worked

 db = MySQLdb.connect(host = 'localhost',user ='root',passwd = '',db
 = 'name_of_my_database')

 But this didn't.

 extract_mysql_models.py --user 'root' --password '' --host
 '127.0.0.1' --database 'name_of_my_database' --dalname 'wikidb'
 --colcomments --singlemigrate  mywiki.py

 Note, my password is empty.

 The error I get is simply that it can't connect to the server. So, I
 am going through the code now.







 On Wednesday, April 22, 2015 at 2:49:41 PM UTC-4, Richard wrote:

 What do you exactly get out of extract_mysql_models.py applied over
 an SQL dump of the schema (only no data inserts)?

 Richard

 On Wed, Apr 22, 2015 at 2:29 PM, Ron Chatterjee 
 achatte...@gmail.com wrote:

 Sorry, wasn't clear. Basically want to create a DAL (db.py) file
 from an existing site that I locally hosted (wAMP) which is php front 
 end
 mysql backend. I exported 

[web2py] Re: LOAD() problem: Yes, I am bungling the world's smallest web2py app.

2015-04-25 Thread Tom Campbell
MAGIC! Thank you, Anthony and Dmitry. I misread Dmitry's code for the view 
and retained the dict() when returning a value from showtasks(), and 
removed showtasks.load. That is completely  wild! Thought I had read the 
book thoroughly before bugging you folks. Thank you.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Ron Chatterjee
I very simple question. Have you tried? Does the script works for you? 
Because it didn't work for me. Idk what you don't understand that I am 
doing. Its all the same code. someone can just step through it and figure 
out that its failing on subprocess.Popen. Idk why its so hard to 
understand. Specially someone as good as you. And I mean it the good way:-).



On Saturday, April 25, 2015 at 6:40:14 PM UTC-7, Richard wrote:

 I don't know what you are doing... As far as I can see the only thing you 
 have to do is to is that you call the script with as argument a valid 
 web2py db connection string...

 a database dump is what is say you dump your db into a file... But I don't 
 think this script work like that, I thought it could work over a file, but 
 it seems to work against a web2py live db connection string...

 Richard

 On Sat, Apr 25, 2015 at 2:21 AM, Ron Chatterjee achatte...@gmail.com 
 javascript: wrote:

 Thanks for all the help Richard. I tried to work around the code 
 extract_mysql_models.py (attached is the code). Basically, I installed 
 XAMP/WAMP and in the phpmyadmin I have the sql database. I am running this 
 code but it fails in line #74:

  p = subprocess.Popen(['mysqldump','--user=%s' % username,'--password=%s' 
 % password,'--skip-add-drop-table','--no-data', 
 database_name,table_name[0]], stdin=subprocess.PIPE, 
 stdout=subprocess.PIPE, stderr=subprocess.PIPE)

 sql_create_stmnt, stderr = p.communicate()


 I don't know what a mysql dump is. Wondering if the above two lines can 
 be written like,


 cat_str = 'SELECT *From' +   + table_name[0]

 get_table = cursor.execute(cat_str)

 sql_create_stmnt = cursor.fetchall()


 And then go on with if 'CREATE' in sql_create_stmnt:


 Anyway, I am attaching the script if it make it makes it any clear.







 On Wednesday, April 22, 2015 at 12:44:08 PM UTC-7, Richard wrote:

 The version in the thread seems not have been included in web2py...

 Try the one in gluon/scripts/

 Richard

 On Wed, Apr 22, 2015 at 3:41 PM, Richard Vézina ml.richa...@gmail.com 
 wrote:

 This regex : regex = re.compile('(.*?):(.*?)@(.*)')

 Seems to parse the below command line call!!

 Richard

 On Wed, Apr 22, 2015 at 3:39 PM, Richard Vézina ml.richa...@gmail.com 
 wrote:


 https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py

 Ok, it is not working exactly how I thought it was... Do you have 
 myslqldump install?

 Do you use Linux or Windows...

 what if you do

 python extract_mysql_models.py username:password@data_basename

 On Wed, Apr 22, 2015 at 3:28 PM, Ron Chatterjee achatte...@gmail.com 
 wrote:

 I used this version (the first one) and change to MySQLdb.

 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 It gives me an error:

 Basically, 

 This worked

 db = MySQLdb.connect(host = 'localhost',user ='root',passwd = '',db = 
 'name_of_my_database')

 But this didn't.

 extract_mysql_models.py --user 'root' --password '' --host 
 '127.0.0.1' --database 'name_of_my_database' --dalname 'wikidb' 
 --colcomments --singlemigrate  mywiki.py

 Note, my password is empty.

 The error I get is simply that it can't connect to the server. So, I 
 am going through the code now. 







 On Wednesday, April 22, 2015 at 2:49:41 PM UTC-4, Richard wrote:

 What do you exactly get out of extract_mysql_models.py applied over 
 an SQL dump of the schema (only no data inserts)?

 Richard

 On Wed, Apr 22, 2015 at 2:29 PM, Ron Chatterjee 
 achatte...@gmail.com wrote:

 Sorry, wasn't clear. Basically want to create a DAL (db.py) file 
 from an existing site that I locally hosted (wAMP) which is php front 
 end 
 mysql backend. I exported out of my WAMP (phpmysqladmin) the tables 
 and 
 fields in SQL language. Then I tried to make DAL out of it. As you 
 explained, thats not possible, Now I will try to take a stab at 
 working 
 with extract_mysql_models.py but it will probably will require some 
 updates. If nothing works, I can use the MYSQL workbench to connect to 
 the 
 server to draw me the schema and then write the DAL from that. Hope it 
 clear things up now. My bad.



 On Wednesday, April 22, 2015 at 2:04:49 PM UTC-4, Richard wrote:

 Hello Ron,

 The more this thread goes the less I understand what you are 
 trying to acheive... Do you want to translate a SQLite DB into a 
 web2py 
 model? or MySQL DB? If you do have a MySQL server instance your 
 connection 
 string seems correct... But then you have to define the table you 
 want to 
 access in this table or you only have DB connection active which give 
 you 
 notting because the DAL don't know the DB structure...

 Richard

 On Wed, Apr 22, 2015 at 1:30 PM, Ron Chatterjee 
 achatte...@gmail.com wrote:

 This is what I was looking for. 


 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 But homehow the code didn't work for me even when I followed the 
 example 

[web2py] put table._format as default for referenced fields

2015-04-25 Thread Leonardo Pires Felix
Hi, 
There is a better way to put the table format attribute in each referenced 
field that has not a label specified?
My application has now 183 tables so far, and puting one by one is kind of 
boring.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] creating DAL from SQL file

2015-04-25 Thread Ron Chatterjee
Thanks for all the help Richard. I tried to work around the code 
extract_mysql_models.py (attached is the code). Basically, I installed 
XAMP/WAMP and in the phpmyadmin I have the sql database. I am running this 
code but it fails in line #74:

 p = subprocess.Popen(['mysqldump','--user=%s' % username,'--password=%s' % 
password,'--skip-add-drop-table','--no-data', database_name,table_name[0]], 
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

sql_create_stmnt, stderr = p.communicate()


I don't know what a mysql dump is. Wondering if the above two lines can be 
written like,


cat_str = 'SELECT *From' +   + table_name[0]

get_table = cursor.execute(cat_str)

sql_create_stmnt = cursor.fetchall()


And then go on with if 'CREATE' in sql_create_stmnt:


Anyway, I am attaching the script if it make it makes it any clear.







On Wednesday, April 22, 2015 at 12:44:08 PM UTC-7, Richard wrote:

 The version in the thread seems not have been included in web2py...

 Try the one in gluon/scripts/

 Richard

 On Wed, Apr 22, 2015 at 3:41 PM, Richard Vézina ml.richa...@gmail.com 
 javascript: wrote:

 This regex : regex = re.compile('(.*?):(.*?)@(.*)')

 Seems to parse the below command line call!!

 Richard

 On Wed, Apr 22, 2015 at 3:39 PM, Richard Vézina ml.richa...@gmail.com 
 javascript: wrote:


 https://github.com/web2py/web2py/blob/master/scripts/extract_mysql_models.py

 Ok, it is not working exactly how I thought it was... Do you have 
 myslqldump install?

 Do you use Linux or Windows...

 what if you do

 python extract_mysql_models.py username:password@data_basename

 On Wed, Apr 22, 2015 at 3:28 PM, Ron Chatterjee achatte...@gmail.com 
 javascript: wrote:

 I used this version (the first one) and change to MySQLdb.

 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 It gives me an error:

 Basically, 

 This worked

 db = MySQLdb.connect(host = 'localhost',user ='root',passwd = '',db = 
 'name_of_my_database')

 But this didn't.

 extract_mysql_models.py --user 'root' --password '' --host '127.0.0.1' 
 --database 'name_of_my_database' --dalname 'wikidb' --colcomments 
 --singlemigrate  mywiki.py

 Note, my password is empty.

 The error I get is simply that it can't connect to the server. So, I am 
 going through the code now. 







 On Wednesday, April 22, 2015 at 2:49:41 PM UTC-4, Richard wrote:

 What do you exactly get out of extract_mysql_models.py applied over an 
 SQL dump of the schema (only no data inserts)?

 Richard

 On Wed, Apr 22, 2015 at 2:29 PM, Ron Chatterjee achatte...@gmail.com 
 wrote:

 Sorry, wasn't clear. Basically want to create a DAL (db.py) file from 
 an existing site that I locally hosted (wAMP) which is php front end 
 mysql 
 backend. I exported out of my WAMP (phpmysqladmin) the tables and fields 
 in 
 SQL language. Then I tried to make DAL out of it. As you explained, 
 thats 
 not possible, Now I will try to take a stab at working with 
 extract_mysql_models.py but it will probably will require some updates. 
 If 
 nothing works, I can use the MYSQL workbench to connect to the server to 
 draw me the schema and then write the DAL from that. Hope it clear 
 things 
 up now. My bad.



 On Wednesday, April 22, 2015 at 2:04:49 PM UTC-4, Richard wrote:

 Hello Ron,

 The more this thread goes the less I understand what you are trying 
 to acheive... Do you want to translate a SQLite DB into a web2py model? 
 or 
 MySQL DB? If you do have a MySQL server instance your connection string 
 seems correct... But then you have to define the table you want to 
 access 
 in this table or you only have DB connection active which give you 
 notting 
 because the DAL don't know the DB structure...

 Richard

 On Wed, Apr 22, 2015 at 1:30 PM, Ron Chatterjee 
 achatte...@gmail.com wrote:

 This is what I was looking for. 


 https://groups.google.com/forum/#!searchin/web2py/extract_mysql_models.py/web2py/XPoTlzPG7lQ/ngSsMbd6zHAJ

 But homehow the code didn't work for me even when I followed the 
 example like it says. So, I am creating a stand alone version that 
 works 
 with MySQLdb.

  




 On Tuesday, April 21, 2015 at 4:58:52 PM UTC-4, Ron Chatterjee 
 wrote:

 I have sqlite browser. I am guessing its the same like SQlite 
 Manager where someone can import, export csv or sql file. I don't 
 have 
 password in that database and work externally to the python 

 *I guess one possibility will be:*

 import MySQLdb

 import sys

 try:

 db = MySQLdb.connect(host = 'localhost',user ='root',passwd = ' 
 ',db = 'my_dabasename')

 except Exception as e:

 sys.exit('we cant get into the db');

  cursor = db.cursor()

 cursor.execute('SELECT *FROM table')

 results = cursor.fetchall()

 print results


 Once the table is fetched then use the insert_into_table option to 
 create db object.


 But I agree with Niphlod, import, export csv is probably the only 
 way to go around, if it works:-). And also agree 

[web2py] Re: IMPORTANT - WEB2PY CONSULTING

2015-04-25 Thread Stefan van den Eertwegh
Hi Massimo,

I also provide consulting for web2py apps. I was trained at Formatics.

Company: Corebyte (NL)
Adres: www.corebyte.nl

Thanks!

Op zondag 15 februari 2015 23:21:36 UTC+1 schreef Massimo Di Pierro:

 We need to update the list of companies that provide web2py consulting.
 This list is obsolete:

 http://web2py.com/init/default/support

 Some links are broke. Most pages do not even mention web2py. Some of them 
 have a design that is simply not acceptable for a web development company.

 That list will be eliminated. IF YOU WANT TO BE LISTED please update your 
 page to have a decent design and MENTION WEB2PY on the main site. Then 
 respond to this thread by providing an updated link and the country were 
 you incorporated. If you have a self-employed individual list your country 
 of residence.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] web2py update app admin doesn't work anymore

2015-04-25 Thread BlueShadow
Hi I'm running web2py on ubuntu with nginx after updating to the current 
version my appadmin doesn't work anymore.
this is the error I got directly from the appadmin error folder:
S'output'
p2
Stype 'exceptions.ImportError' No module named pydal.objects
p3
sS'layer'
p4
S'/home/www-data/web2py/applications/admin/controllers/default.py'
p5
sS'code'
p6

thanks for your help

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: DB2 database issue with Clob types

2015-04-25 Thread Paolo Valleri
you should provide us more info...
which web2py type are you using that is mapped to CLOB field?
web2py/pyodbc version

Paolo

On Friday, April 24, 2015 at 6:17:53 PM UTC+2, Boris Aramis Aguilar 
Rodríguez wrote:

 class pyodbc.Error' ('ODBC data type -99 is not supported. Cannot read 
 column LDTEXT.', 'HY000') 

 Hi, Im currently accesing a DB2 database (readonly) that is used by 
 another application, my connection string is as follows: 

 db_tivoli = 
 DAL('db2:pyodbc://driver=DB2;hostname=24.50.5.5;database=MAXDB71;uid=on_usr;pwd=pass.;port=50005',
  
 pool_size=1, db_codec='latin1', migrate=False) 

 and everything was going fine until I added a clobdata type to web2py data 
 code 

 And now I'm getting the error I referenced above (sorry I couldnt paste it 
 in order, Im on my phone) Any hints I would appreciate it :)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to remove application name from urls generated from a scheduled task?

2015-04-25 Thread Niphlod
there's nothing fancy in the scheduler that alters the environment at 
runtime: it's no different from a web2py shell. can you post your routes, 
your desired urls and the code that generates them ?

On Friday, April 24, 2015 at 6:37:43 PM UTC+2, Lisandro wrote:

 I'm using parametric based routes for mapping each domain with its 
 corresponding app. Because of this, when I use the URL() helper, the 
 application name isn't included in the resulting url, and that is perfect 
 for me. However, inside a scheduled task, the URL() helper generates urls 
 including the app name. 

 Both urls (with and without application name) work ok. But considering 
 they are urls for public content, I don't like the idea of having two 
 different urls with the same content, I think it could be 
 counter-productive for SEO and related stuff.

 Is there a way to avoid the inclusing of app name in urls generated from 
 sheduled tasks?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to remove application name from urls generated from a scheduled task?

2015-04-25 Thread Lisandro
This is my routes.py:

# -*- coding: utf-8 -*-
routers = dict(\
  BASE = dict(\
default_controller = 'default', \
default_function = 'index', \

domains = {\
  'website.dev':'website', \
  'panel.website.dev':'website_panel', \
}, \

root_static = ['robots.txt'], \
map_static = True, \
exclusive_domain = True, \
  )\
)

The website application has a function called article, defined in the 
default.py controller. 
That function renders the view for an article, which id is received in the 
first argument, as an integer. 
In order to generate the link to each article, I've defined Virtual Method 
on the articles table, like this:

db.articles.url = Field.Method(lambda row: \
  URL('default', 'article', args=row.articles.id, scheme=True, 
host='website.dev')) 


When I call that method from any place (controllers, views), the link 
generated is ok (doesn't include app name neither default controller). This 
is how I call the method:

for article in db(db.articles).select():
print article.url()

This is an example of a link generated:
http://website.dev/article/425

But when I call the same method from a function defined on 
models/scheduler.py, the link generated includes the app name, like this:
http://website.dev/website/article/425

Both links work ok, but I think it's not good to have multiple links with 
same content (counter-productive for SEO, I think). 
I'm using nginx. Now I don't have any rewrite rule. I know I could write 
some rule to let nginx remove the appname from the url, but I'm still 
wondering why the virtual method is including the app name when called from 
scheduled task.

El sábado, 25 de abril de 2015, 9:52:39 (UTC-3), Niphlod escribió:

 there's nothing fancy in the scheduler that alters the environment at 
 runtime: it's no different from a web2py shell. can you post your routes, 
 your desired urls and the code that generates them ?

 On Friday, April 24, 2015 at 6:37:43 PM UTC+2, Lisandro wrote:

 I'm using parametric based routes for mapping each domain with its 
 corresponding app. Because of this, when I use the URL() helper, the 
 application name isn't included in the resulting url, and that is perfect 
 for me. However, inside a scheduled task, the URL() helper generates urls 
 including the app name. 

 Both urls (with and without application name) work ok. But considering 
 they are urls for public content, I don't like the idea of having two 
 different urls with the same content, I think it could be 
 counter-productive for SEO and related stuff.

 Is there a way to avoid the inclusing of app name in urls generated from 
 sheduled tasks?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: ghost scheduler workers can never be deleted even the web2py-schduler is stopped.

2015-04-25 Thread Niphlod
there's nothing that magically insert records on the scheduler_worker 
table. watch the last_heartbeat column and see if it changes. If it's 
changing, the workers are still running somewhere and accessing your 
database.

On Friday, April 24, 2015 at 9:24:59 PM UTC+2, Pengfei Yu wrote:

 Hi I am using web2py scheduler. I have a project saved in git and then I 
 cloned this git repository to another new instance (server). In the new 
 server, five scheduler workers (known from the ip address in the 
 worker_name) from the old server are always there. When never I delete 
 them, they will automatically generated soon. And it seems that they 
 inherited the scheduler task program from the old server. After I updated 
 the scheduler task program, it is not updated for these five ghost worker. 
 Each time I initiate a new task, it will be assigned to these 5 workers 
 first, and the updated task program will never be run. Could any one tell 
 me how to git rid of these ghost workers.

 Thanks! 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Trying to persist a DAL connection to save time connection

2015-04-25 Thread Michel Krav

Thanks anthony, 

I thought I'd be critized the hard way by some experienced users,
so thanks for your quick, constructive and straightforward response, as 
always.

I really appreciate the quality of your job in web2py and the job for 
animating this user group.

I admit not read the entire book, it's huge... but step by step I will 
finally cover it. 




Le mardi 21 avril 2015 17:09:28 UTC+2, Anthony a écrit :

 You should use the built-in connection pooling mechanism for this purpose. 
 See 
 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Connection-pooling
 .

 Anthony

 On Tuesday, April 21, 2015 at 11:05:32 AM UTC-4, Michel Krav wrote:

 Hi,
 my goal is to save time at each request processing.

 my context is a connection to an Oracle database with unfortunately poor 
 network response, so 
 in model.py , defining : 
 dbo =  DAL(uri , auto_import = False, migrate = False , lazy_tables = 
 False)
 on every request it cost time to connect.

 So, I decided to save the DAL object in a global variable.
 I prefered  doing
 current.dbo = dbo
 than 
 session.dbo = dbo 
 in the model file, as it's not user dependent.

 and finally store it in the application cache :
 current.dbo = cache.ram('dbo', lambda: dbo , time_expire=60*60)

 then I only define table in other model/file dedicated to controller in a 
 conditional model way.

 after test and debug it seems to work well (fell like saving time 
 connection) but is it web2py proofed ? 






-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: csv download problem from an SQLFORM.grid populated by an AJAX call

2015-04-25 Thread drmbded


 While putting together an example of the error I found that my example 
 worked fine, in fact I'm getting HTML instead of CSV from a grid that was 
 not created from an AJAX call.


This must be something that I've cause but with such a simplified 
application I'm stumped as to what is causing this. 

Looking through the HTML I can see my error printed out from the traceback 
and here's what it shows:

got an error: (200 OK) Traceback (most recent call last):
   File 
quote;/opt/web2py/applications/testApp/controllers/audit.pyquote;, line 
32, in auditUsers
   grid=SQLFORM.grid(dbOra.personnel)
   File quote;/opt/web2py/gluon/sqlhtml.pyquote;, line2225, in grid
  raise HTTP(200, oExxp.export(), **response.headers)
HTTP: 200 OK

 

My controller is very simple:

def auditUsers():
   try:
  grid=SQLFORM.grid(dbOra.personnel)
   except Exception, err:
  grid='got an error: (%s) %s' %(str(err), traceback.format_exc())
   return(message=done,grid=grid)

And my view is just as simple:

{{right_sidebar_enabled,left_sidebar_enabled,('message' in globals())}}
{{extend 'layout.html'}}

h1{{=message}}/h1
{{=grid}}


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: AJAX div reload indicator

2015-04-25 Thread Gary Cowell
I've tried twice before to post my solution on this, but here's a third try:

So I solved this for my app, in the following way. For reference for 
others, and for comment if I'm doing something stupid. But, this works for 
me:

In my view:
{{=LOAD('tenant','stackList.load',ajax=True, target=stackList,vars={
'reload_div':'stackList'},content=CENTER(IMG(_src=URL(request.application,
'static','images/ajax_loader_blue_256.gif'}}

I'm using my 'tenant' 'stackList' controller. This content= tag, handles 
the AJAX preload spinner upon page load.   When the component is told to 
refresh, using (in another controller):

spinner=CENTER(IMG(_src=URL(request.application,'static',
'images/ajax_loader_blue_256.gif')))
response.js = 
jQuery('#stackList').html('{0}');jQuery('#stackList').get(0).reload().
format(spinner)

I define my image to use, and then my response has two jQuery calls, the 
first replaces my #stackList div with the spinner image, and the second 
calls the ajax reload.

So when I click the refresh action on the page, the div is replaced 
immedialey with a preload spinner, and then some seconds later, the data 
appears.  It would look more elegant perhaps if I were to fade out the div 
instead. I don't know, but if you can do it with jQuery, you could do it 
like this.

Actually I think my solution ended up being much simpler than almost any 
example of this I've seen so perhaps it can help some people.

On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:

 Hello

 I have a DIV component I'm reloading using another controller , so I end 
 up calling:

response.js = jQuery('#stackList').get(0).reload()

 Problem is, my stackList controller function does a lot of work to rebuild 
 the grid, it makes many AWS api calls, to populate the grid.

 The reload works, and the grid eventually updates, but there is no 
 indication that it's doing anything, it has the old values for ages (well, 
 10 seconds or so, seems like ages) after the other form is submitted then 
 it snaps to its new output.

 How can I make the div update immediately with a spinning 'progress' , or 
 maybe fade it out at the start of the refresh, and in at the end? Anything 
 to provide a visual clue that the controller function is running, and that 
 the display is stale

 Thanks


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] unicode error with postgre on 2.10.3 (with sample app)

2015-04-25 Thread bodobammel
Hey guys,

2.10.3 doesn't seem ready for prime time :-( In fact this bug makes 2.10.3 
unusable for postgres users with need for non ASCII-characters..

For reference let's link to the corresponding issue here too: 
https://github.com/web2py/web2py/issues/910

Is there any solution yet?

Bodo

Am Samstag, 11. April 2015 16:38:13 UTC+2 schrieb Ian W. Scott:

 Thanks Richard. My production server is working fine with 2.9.11. I'll 
 open an issue on the web2py github repo, since it sounds like that's the 
 better forum for this.

 Ian


 On Friday, April 10, 2015 at 3:40:16 PM UTC-4, Richard wrote:

 Ok, ok, I guess there is an issue with web2py or pyDAL... Can you test 
 this with an earlier version of web2py? If it works consider open an issue 
 in web2py on github with condition to reproduce the error and if it coming 
 form pyDAL the issue will be migrate to pyDAL repo once the origin of the 
 issue is found.

 Richard

 On Fri, Apr 10, 2015 at 3:24 PM, Ian W. Scott scot...@gmail.com wrote:

 Also, as I pointed out in my question I can insert the same string (with 
 the same encoding) directly into the postgre database using the raw SQL 
 code that is being sent by pydal to the postgre adapter. I inserted a print 
 statement into adapters/base.py to give me the exact SQL command, copied 
 that SQL command (data and all), then ran it in pgAdmin with no problem. So 
 it can't be a problem with the encoding of the string being received by the 
 pydal.

 Ian

 On Friday, April 10, 2015 at 2:05:25 PM UTC-4, Richard wrote:

 Can you please show the code that lead to this error?

 If you hard code this you can't use a regular string (str()) which is 
 ascii characters only you have to pass by unicode something like this :

 string = u'ἀγοραζε'.decode(utf-8)

 http://stackoverflow.com/questions/6289474/working-
 with-utf-8-encoding-in-python-source

 If the greek character come form user input web2py deal with this to my 
 knowledge... So I am pretty sure you hard code greek character in your 
 code... So you need to read about encoding in python...

 Richard



 On Fri, Apr 10, 2015 at 1:29 PM, Ian W. Scott scot...@gmail.com 
 wrote:

 Hi folks,

 I'm running into an error with 2.10.3 when I try to write unicode text 
 (outside the Latin ranges) to a regular string field in a postgre 
 database. 
 Since my app is a greek language-learning application this error breaks 
 things completely for me.

 When I try, for example, to insert the string 'ἀγοραζε' I get the 
 following error:

 Traceback (most recent call last):

   File applications/paideia/modules/paideia.py, line 168, in start
 pre_bug_step_id=pre_bug_step_id)
   File applications/paideia/modules/paideia.py, line 384, in reply
 response_string)
   File applications/paideia/modules/paideia.py, line 655, in 
 _record_step
 log_record_id = db.attempt_log.insert(**log_args)
   File /home/ian/web/web2py/gluon/packages/dal/pydal/objects.py, 
 line 745, in insert
 ret =  self._db._adapter.insert(self, self._listify(fields))
   File /home/ian/web/web2py/gluon/packages/dal/pydal/adapters/
 base.py, line 729, in insert
 raise e
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 
 105: ordinal not in range(128)


 The SQL being sent to the postgre adapter in this case was this:

 INSERT INTO attempt_log(name,user_response,step,score,modified_on,dt_
 attempted,in_path,uuid) VALUES (19,'ἀγοραζε',773,1.0,'2015-04-10 
 12:33:25','2015-04-10 16:33:26',657,'5918a65a-6d6f-
 42c6-9af2-f5d0e313701e') RETURNING id;

 When I execute that SQL command directly on the postgre database it 
 doesn't raise any errors and the new row is created fine.

 I've created a simple app that duplicates the error and attached the 
 packed app here. Since the error doesn't happen with sqlite, I've set up 
 the app db for a postgre database with the following connection details:

 username = 'postgres'
 postgre host = 'localhost'
 postgre db_name = 'unicode_bug_test'

 I've left the db password field empty in the db.py file for obvious 
 reasons (i.e., my local password wouldn't do anyone any good anyway).

 If you try to create a new record in the 'lemmas' table using appadmin 
 with non-Latin text in the 'lemma' field (something like 'βλα') you 
 should 
 get the same error.

 Ian

 -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google 
 Groups web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to web2py+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You 

[web2py] Re: alternate date and time picker

2015-04-25 Thread Lieven Van Acker
Hi Greg,

I'm trying to integrate the date and time picker from Pickadate.js, but 
seem to have some problems with the styling, e.g. the dates table width is 
only taking half of the widget with, and styling of the header is different 
from the expected (default) styling as experienced 
on http://amsul.ca/pickadate.js/date/. 

this is the include order in web2py_ajax.html:

response.files.insert(0,URL('static','js/jquery.js'))
response.files.insert(1,URL('static','css/calendar.css'))
response.files.insert(2,URL('static','js/calendar.js'))
response.files.insert(3,URL('static','css/pickadate/default.css'))
response.files.insert(4,URL('static','css/pickadate/default.date.css'))
response.files.insert(5,URL('static','js/pickadate/picker.js'))
response.files.insert(6,URL('static','js/pickadate/picker.date.js'))
response.files.insert(7,URL('static','js/pickadate/legacy.js'))
response.files.insert(8,URL('static','js/web2py-custom.js'))

using web2py-custom.js

...
var date_format = (typeof w2p_ajax_date_format != 'undefined') ? 
w2p_ajax_date_format : %Y-%m-%d;
doc.on('click', input.date, function () {date
 var tformat = $(this).data('w2p_date_format');
 var active = $(this).data('w2p_date');
 var format = (typeof tformat != 'undefined') ? tformat : date_format;
 if(active === undefined) {
 $(this).pickadate({
 firstDay: 1,
 selectYears: 4
 });
 //Calendar.setup({
 // inputField: this,
 // ifFormat: format,
 // showsTime: false,
 // fdow: 0
 //});
 $(this).data('w2p_date', 1);
 $(this).attr('autocomplete', 'off');
 $(this).trigger('click');
 }
});

...

I guess I'm missing something here, but can't figure out.

Any idea's on this?

Thanks for sharing pickadate,

Lieven

Op maandag 21 april 2014 11:19:44 UTC+2 schreef Greg Vaughan:

 Hi Annet...

 Thank you so much for the detailed reply... I have made it a point to 
 check out the styling you have done...

 However the issue that I have is not just with the look but also with the 
 way that the default one functions... particularly on tablets... it is 
 clunky.

 So I have hacked together an implementation of Pickadate.js 
 http://amsul.ca/pickadate.js/index.htm which is the sort of thing my 
 clients expect in a modern browser application.

 Cheers
 Greg


 On Sunday, 20 April 2014 16:36:25 UTC+10, Annet wrote:

 Hi Greg,

 I use a customized version of jQuery UI (I only needed the datepicker and 
 autocomplete)...

 ...

 Kind regards,

 Annet



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Pydal ilike search inside a list of strings?

2015-04-25 Thread Tom Stratton
Hi -

I'm struggling to find a way to do an ilike style search within a list of 
strings field in the db.

For example, my field may contain ['Donald Duck', 'Minnie Mouse']

I'd like that record returned when I am searching for '%mouse%'

Maybe I need to cast the list to a string but this is just part of a larger 
query and I'm hoping for a simpler, built in, solution.

Thanks

Tom

PS - what does it take to get posting permissions? I feel like I would 
participate more if my answers didn't get help overnight ;-)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: database chema recommendations needed

2015-04-25 Thread John
Gramps is a desktop program for building a family tree. We have a web based 
version that we're fine with although I'd like to tie it into the actual 
site sometime for joint login purposes. This other part of the site is the 
individual transcriptions of old records. The data you would reference/cite 
as sources for facts in doing research for building a family tree. 
Upon further thought, places (State, County, CityTown) be best in it's own 
table so they each only get stored once. 

On Tuesday, April 21, 2015 at 10:05:32 AM UTC-5, John wrote:

 New to programming and web2py. Been dabbling in web design for a while, 
 building sites with wordpress, plugging things in. My first real project 
 will be a site/app for my sister. Genealogical resources. Lots of records 
 that will need to be added via csv and also via forms. Will also need to be 
 displayed in sortable grid/table format and will need advanced search 
 capabilities. These records will be things like births, deaths, marriages 
 etc and would have anywhere from 10-20 fields for things like; surname | 
 given name(s) | DOB | State | County | City/Town | Father surname | father 
 given name | mother surname | mother given name | source.
 On the site, people would most likely browse by clicking a State, then the 
 County and then Birth records at which point they would see the sortable 
 grid/table with all birth records for that County, State. 
 Else they would go to an advanced search page where they would choose the 
 record type from a drop down, State from a drop down which would then 
 populate a drop down for Counties of the chosen State. A choice for all 
 States/Counties would be nice. Names, they would type in. DOB could be 
 typed in as well though it would be nice if they could choose a date or 
 date range. Some records may only have a partial date like maybe just the 
 year. 
 Each record type will have all the same fields of course so it only makes 
 sense to have a table for each. There will be approx 20-30 different record 
 types. I thought about individual tables for each record type for each 
 state but that would be 51 tables(50 States plus DC) times however many 
 record types there ends up being so 1000-1500 tables. Seems like too many. 
 I'm in no rush and realize I have a lot of work to do and a lot to learn. 
 At some point this site will hopefully become a community based site so 
 membership and permissions will be needed. A forum would be nice but I 
 haven't seen anything regarding that in the documentation yet. But first 
 and foremost is the data records. I've read that each application gets it's 
 own database so I'm thinking my first/main app would be *Records* with db 
 tables for births, deaths, marriages etc. Am I correct in thinking that a 
 table for each record type would be best and to not break it down by State 
 but rather make State a field/column? Then again, when/if we end up with 
 lots of records, that would be a lot of rows considering the number of 
 births in the USA over a period of a few centuries. 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: auth.wiki()

2015-04-25 Thread Ben Lawrence
It works now for me. All I had to do was add a tag to one of the pages. 
Seems search doesn't work for empty tag table.

On Tuesday, April 21, 2015 at 8:26:44 AM UTC-7, Alex Glaros wrote:

 no, did not get it to work, but submitted bug report.  You can follow 
 progress of bug report here:

 https://github.com/web2py/web2py/issues/911

 I have not gotten back to working on it but it's pretty easy for even a 
 beginner to write their own search




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: [OT] HTML to PDF

2015-04-25 Thread Ariya Owam-aram
Hi,

Now it work very well on my site and can be run on NginX

step


   1. download : 
   
http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
   2. install : (from command line)
  1. dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
  2. cp /usr/local/bin/wkhtmltopdf /usr/bin/
   3. in controller

   - def print_from_list__pdf():
  
  1.  import
 2. import os, re
 3. from subprocess import call
 4. 
 5.  set source and result path
 6. body_html_path   = os.path.join(request.folder, static, 
 template/contact_lists__print_from_list__body.html)
 7. header_html_path = os.path.join(request.folder, static, 
 template/contact_lists__print_from_list__header.html)
 8. footer_html_path = os.path.join(request.folder, static, 
 template/contact_lists__print_from_list__footer.html)
 9. result_pdf_path  = os.path.join(request.folder, static, 
 template/%s.pdf %print_job__id)
 10.  print process
 11. # body
 12. html = response.render('contact_lists/print_from_list.html', 
 dict(smart_search=smart_search, user__id=user__id)) 
 13. file(body_html_path, wb).write(html)
 14. # header
 15. 
 16. html = response.render('print_template/letter_head_cac.html', 
 dict(page_title = 'Contact Lists', user__id = user__id))
 17. file(header_html_path, wb).write(html)
 18. # footer
 19. html = response.render('print_template/letter_footer_cac.html')
 20. file(footer_html_path, wb).write(html)  
 21. call('wkhtmltopdf --margin-top 50mm --margin-left 10 
 --margin-right 10 --margin-bottom 30mm  %s --header-html %s 
--footer-html 
 %s  %s' %(body_html_path, header_html_path, footer_html_path, 
 result_pdf_path), shell=True
  4. for Apache you can run call subprocess with no problem but in 
   Nginx you have to run in web2py scheduler
   5. My case I use schedule to run and stream upload to print spooler 
   table, after print user have to open spooler for print.

https://lh3.googleusercontent.com/-KVYRGdh_M_0/VTcBwRDM5zI/AP0/sl43fdl7KnQ/s1600/Screen%2BShot%2B2558-04-22%2Bat%2B9.01.33%2BAM.png

Hope it help.

Ariya


เมื่อ วันอังคารที่ 21 เมษายน ค.ศ. 2015 20 นาฬิกา 19 นาที 47 วินาที UTC+7, 
Ovidio Marinho เขียนว่า:

 Hello Arya,

 How did you do this can publish the code?





[image: http://itjp.net.br] http://itjp.net.br
  http://itjp.net.b http://itjp.net.brr
   *Ovidio Marinho Falcao Neto*
  ovid...@gmail.com javascript:
 Brasil
  

 2015-01-15 10:54 GMT-03:00 Ariya Owam-aram ariya.ca...@gmail.com 
 javascript::

 Hi Bruno,

 I install wkhtmltopdf and integrate with web2py by using subprocess.call, 
 it work very well on my macbook (rocket server). But I can't success 
 running subprocess.call on production server (Ngix). I also test 
 subprocess.call wkthtmltopdf from web2py's shell (admin) it return non-zero 
 number as output. (nothing comeout)

 But suprocess.call wkhtmltopdf is working well in the web2py shell 
 (python web2py.py -S app -M).

 Now I don't know where to go next?

 Can you please tell me what I missing.

 Thank you in advanced.
 Ariya 

 On Thursday, December 6, 2012 at 3:36:50 AM UTC+7, rochacbruno wrote:

 I found this excellent command line tool: 
 http://code.google.com/p/wkhtmltopdf/

 It generates the PDF qith a very nice quality and I see it is easy to 
 integrate on web2py applications using pysh or subprocess.

 http://code.google.com/p/wkhtmltopdf/


 *Bruno Cezar Rocha** - @rochacbruno*
 rocha...@gmail.com | Mobile: +55 (11) 99210-8821
 www.CursoDePython.com.br | www.rochacbruno.com.br
 Blog: microblog app http://rochacbruno.com.br/microblog-app/
   Get a signature like this. 
 http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18
  Click 
 here. 
 http://r1.wisestamp.com/r/landing?promo=18dest=http%3A%2F%2Fwww.wisestamp.com%2Femail-install%3Futm_source%3Dextension%26utm_medium%3Demail%26utm_campaign%3Dpromo_18


  
  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list 

[web2py] Capture XML response into string for further parsing with ElementTree

2015-04-25 Thread NeoToren
Amazon Payments responds to a website with XML.
Amazon doesn't send back an XML to my site - it just displays XML - at the 
same URL my website sent a well formed, hashed and signed message.
I need to parse the Amazon XML response into meaningful variables for 
moving forward with the purchasing workflow.

ElementTree can parse XML if fed with a file or a string.
As far as I know ElementTree cannot read directly from an htttp address.
Thus I need scrape the XML from the screen / that URL into a string to feed 
ElementTree.

How can I capture the XML into a string for further parsing
... or better still...
Any magic to capture AND parse from a URL in a short and sweet way ?

Thanks

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: routes.py breaking login...

2015-04-25 Thread Tom Stratton
Thanks Anthony!

In the end I added this to db.py:
```

auth.settings.controller = 'pkg'
auth.settings.login_url = URL 
https://bsttemp.pythonanywhere.com/examples/global/vars/URL('pkg', 'user')

```
and it all worked out 

On Saturday, April 18, 2015 at 8:15:45 AM UTC-7, Anthony wrote:

 Auth assumes the login actions are available at /default/user. If you 
 change that, you have to tell Auth. The easiest way is upon initialization:

 auth = Auth(db, controller='pkg', function='my_user_function')

 Alternatively, you can subsequently change settings such as 
 auth.settings.controller and auth.settings.function, but then you also have 
 to change a number of settings that are based on those values, such as 
 auth.settings.login_url, auth.settings.logged_url, etc. So, it is easiest 
 to specify the controller and function when initially constructing the Auth 
 object.

 Note, you will also have to move the /views/default/user.html view to 
 /views/pkg/user.html (and change user.html to match the name of your new 
 user action if you have changed that).

 Anthony

 On Friday, April 17, 2015 at 10:50:37 PM UTC-4, Tom Stratton wrote:

 Hi -

 I wanted to change my default application and did some research.

 First I did the simple:
 ```
 default_application='p'
 default_controller = pkg
 default_function = packages
 ```
 And it seemed to work fine but I was not satisfied so I did this:
 ```
 routers = dict(
   BASE  = dict(default_application='p', default_controller='pkg'),
 )
 ```

 This seemed to work fine too - BUT… Then my login session expired and I 
 see this URL:
 https://bsttemp.pythonanywhere.com/default/user/login?_next=/packages

 How can I make the login happen at my preferred controller instead of 
 in the default one? (I had deleted the default.py controller after my 
 limited testing worked)

 Thanks

 Tom



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Combine IS_IN_DB and IS_NOT_IN_DB

2015-04-25 Thread kecajkecaj123
Hi Guys, 

I have simple database:

db.define_table('ipaddress',
   Field('ip', unique=True, length=200),
   Field('subnet', length=200),
   format = '%(ip)s')

db.define_table('server',
   Field('servername', length=200),
   Field('port', length=200),
   Field('ipaddress_id', 'reference ipaddress'))

I have few records in ipaddress table and not would like to add some 
validators. 
When adding record to server table i would like to check if ipaddress_id 
exist in ipaddress table AND if it hasn't been used before in server table.
That can be done by doing:

db.server.ipaddress_id.requires = IS_IN_DB(db,db.ipaddress.id, '%(ip)s') 
,IS_NOT_IN_DB(db,db.server.ipaddress_id, '%(ip)s')]

But in that case Filed server.ipaddress_id is not a dropdown menu and it's 
not presented as %(ip)s. I would like to have dropdown to choose IP 
available in ipaddress table, but just the one which hasn't been used 
before. Any tips? 

Thanks, 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: AJAX div reload indicator

2015-04-25 Thread Gary Cowell
I found that I can use:

{{=LOAD('tenant','stackList.load',ajax=True, target=stackList,vars={
'reload_div':'stackList'},content=CENTER(IMG(_src=URL(request.application,
'static','images/ajax_loader_blue_256.gif'}}

So this gives me a spinner gif inside my component div on page reload.

It doesn't give me a spinner though, when 

response.js = jQuery('#stackList').get(0).reload()

is called.

So my question still stands, the reload time for my stackList controller is 
quite long, looks okay on page load, but spinner is missing on refresh.

Do I have to do something more to get the spinner to work on refresh, or 
should I be doing my component refresh a different way?



On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:

 Hello

 I have a DIV component I'm reloading using another controller , so I end 
 up calling:

response.js = jQuery('#stackList').get(0).reload()

 Problem is, my stackList controller function does a lot of work to rebuild 
 the grid, it makes many AWS api calls, to populate the grid.

 The reload works, and the grid eventually updates, but there is no 
 indication that it's doing anything, it has the old values for ages (well, 
 10 seconds or so, seems like ages) after the other form is submitted then 
 it snaps to its new output.

 How can I make the div update immediately with a spinning 'progress' , or 
 maybe fade it out at the start of the refresh, and in at the end? Anything 
 to provide a visual clue that the controller function is running, and that 
 the display is stale

 Thanks


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: AJAX div reload indicator

2015-04-25 Thread Gary Cowell
I think I found my solution, in my controlling function when I send the 
response.js for the reload, I'm doing it like this now:

spinner=CENTER(IMG(_src=URL(request.application,'static',
'images/ajax_loader_blue_256.gif')))
response.js = 
jQuery('#stackList').html('{0}');jQuery('#stackList').get(0).reload().
format(spinner)



So instead of just sending the div a reload, I'm using a JQUERY call to 
replace the DIV with a CENTER IMG of my spinner.

It seems to work, can anyone think why this is a bad idea?


On Tuesday, 21 April 2015 16:05:32 UTC+1, Gary Cowell wrote:

 Hello

 I have a DIV component I'm reloading using another controller , so I end 
 up calling:

response.js = jQuery('#stackList').get(0).reload()

 Problem is, my stackList controller function does a lot of work to rebuild 
 the grid, it makes many AWS api calls, to populate the grid.

 The reload works, and the grid eventually updates, but there is no 
 indication that it's doing anything, it has the old values for ages (well, 
 10 seconds or so, seems like ages) after the other form is submitted then 
 it snaps to its new output.

 How can I make the div update immediately with a spinning 'progress' , or 
 maybe fade it out at the start of the refresh, and in at the end? Anything 
 to provide a visual clue that the controller function is running, and that 
 the display is stale

 Thanks


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] upload field

2015-04-25 Thread KevC
Hi!

I want to upload a file type .PDF in upload field but I only aceept this 
type of file.

What can I do?



I hope you can help me.
Best regards.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: dynamically add rows to html table

2015-04-25 Thread Lieven Van Acker


 ...

 

 Use the same function to populate the div on initial page load as you do 
 to from the ajax call. Note it's handy to have that function easily 
 callable from something that's not ajax for debugging, as ajax hides the 
 error message.



Can you provide an example on how to include  the ajax function in a view 
to be executed upon initial load?

Thanks,

Lieven

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Failed login attempt lockout

2015-04-25 Thread 黄祥
the idea is base on wordpress plugin 'limit login attempts', that i want to 
achieve it using web2py. 
first i want to start from simple, just record the attempted times in 
database table, 
after that, banned ip user for several time (minutes or hours) if the 
failed login is reached max retries times (e.g. 3 times), till the record 
in database is reseted by admin the user can try the login, during the ip 
banned, is redirect to another page.
how to achieve it using web2py?

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] How to set a condition with @auth.requires_login in Web2py

2015-04-25 Thread Christophe Meessen
In my web2py web app, the controller function def index(): has the 
decorator @auth.requires_login(). 

For development and testing purpose I comment out this decorator. But I 
often forget to uncomment it before committing the code. 

I would like to change this decorator into something that would test if a 
file is present (i.e. skipLogin) and if not to require login. I can then 
add the skipLogin file in my .gitignore file and don't need to worry about 
commenting and uncommenting the decorator line. 

I suppose it should be something like @auth.requires(lambda: xxx) but I 
have no idea what xxx should be. 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to set a condition with @auth.requires_login in Web2py

2015-04-25 Thread 黄祥
perhaps you can do something like :
if auth.is_logged_in():
e.g.
*models/menu.py*
if auth.is_logged_in():
response.menu = [
(T('Test'), False, URL('default', 'index'), [
(T('Test'), False, URL('default', 'test'), []),
]), 
]

best regards,
stifan



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Combine IS_IN_DB and IS_NOT_IN_DB

2015-04-25 Thread 黄祥
perhaps you can use unique=True on your table 'server'
e.g. 1
db.define_table('server',
   Field('servername', length=200),
   Field('port', length=200),
   Field('ipaddress_id', unique=True, 'reference ipaddress'))
   
db.server.ipaddress_id.requires = IS_IN_DB(db,db.ipaddress.id, '%(ip)s')

another thing, is you can use query for that.
e.g.2
db.define_table('ipaddress',
   Field('ip', unique=True, length=200),
   Field('subnet', length=200),
   Field('status', length=200),   
   format = '%(ip)s')

def __after_insert_server(f, id):
db(db.ipaddress.id == f.ipaddress_id).update(status = T('Recorded') )
db.ipaddress.status.default = T('Unrecorded')
db.server._after_insert.append(__after_insert_server)
db.server.ipaddress_id.requires = IS_IN_DB(db(db.ipaddress.status == 
T('Unrecorded') ), db.ipaddress.id, '%(ip)s')

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: upload field

2015-04-25 Thread 黄祥
perhaps you can use validators on form level.
e.g.

requires = IS_UPLOAD_FILENAME(extension='pdf')

ref:
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Special-type-validators

best regards,
stifan

On Saturday, April 25, 2015 at 10:28:10 PM UTC+7, KevC wrote:

 Hi!

 I want to upload a file type .PDF in upload field but I only aceept this 
 type of file.

 What can I do?



 I hope you can help me.
 Best regards.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: web2py update app admin doesn't work anymore

2015-04-25 Thread 黄祥
what version did you use right now?
if i'm not wrong in the newest version got the pydal modules separate.
please download and unzip from web2py website.

ref:
http://web2py.com/books/default/chapter/29/14/other-recipes#Upgrading
http://web2py.com/init/default/download

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to avoid error when app is renamed and sessions are stored in db and shared through domains?

2015-04-25 Thread Lisandro
If by chance someone is dealing with the same problem and using nginx, 
here's a temporary fix: edit your virtual host configuration, and add this 
lines inside the server {} block directive:

location /appname/ {
rewrite ^/appname/(.*)$ $scheme://mydomain.com/$1 redirect;
}



El jueves, 23 de abril de 2015, 15:57:57 (UTC-3), Lisandro escribió:

 I could get it to work, however I'm still concerned about something.
 This is what I have and it is working:

 session.connect(request, response, db=db, masterapp='init')
 response.cookies[response.session_id_name]['domain'] = 'website.com'

 As I said before, the two apps were renamed, keeping the database. 
 So, regardless the new applications names, the session table is still 
 named web2py_session_init, and that's why I think it is working with 
 masterapp='init'.

 However, should I be worried about setting masterapp with an app that 
 doesn't exist? The book says If you want two or more applications to share 
 sessions, set masterapp to the name of the master application., but I 
 coundn't find specifications about if that app should exist or not.

 El jueves, 23 de abril de 2015, 11:36:42 (UTC-3), Lisandro escribió:

 I have two apps running on production: init app, and panel app.
 Both of them are using the same database (symlinked models and databases 
 folder).
 The sessions are stored in the db.
 The main app is init, so I'm connecting to session like this:

 session.connect(request, response, db=db, masterapp='init')

 In the database, I can see that the session table is called 
 web2py_session_init.


 Now I need to rename both apps and serve both of them on domaind and 
 subdomain, so I did this:
  - renamed init to *website*; the app is now served on *website.com 
 http://website.com* domain.
  - renamed panel to *website_panel*; the app is now served on 
 *panel.website.com 
 http://panel.website.com* domain

 The main app now is website_panel.

 In order to mantain sessions through main domain and subdomain, I added 
 this sentence after the session.connect, so I ended up with this:
 session.connect(request, response, db=db, masterapp='init')
 response.cookies[response.session_id_name]['domain'] = 'website.com'

 But I'm receiving this error:

 Traceback (most recent call last):
   File /home/gonguinguen/medios/gluon/restricted.py, line 227, in 
 restricted
 exec ccode in environment
   File /home/gonguinguen/medios/applications/website/models/db.py 
 http://fundapres.dev/admin/edit/fundapres/models/db.py, line 10, in 
 module
 response.cookies[response.session_id_name]['domain'] = 'website.com'
 KeyError: 'session_id_init'



 First thing I tryied was to change masterapp parameter value, like this:
 session.connect(request, response, db=db, masterapp='website_panel')
 response.cookies[response.session_id_name]['domain'] = 'website.com'

 but in this case, an error is raised saying that the table 
 web2py_session_website_panel doesn't exists.
 I'm not shure why web2py doesn't create the table. I have migrations 
 enabled,


 I also tryied manually renaming the table and the corresponding file 
 under databases folder, but in this case I receive the following error:

 Traceback (most recent call last):
   File /home/gonguinguen/medios/gluon/restricted.py, line 227, in 
 restricted
 exec ccode in environment
   File /home/gonguinguen/medios/applications/website/models/db.py 
 http://fundapres.dev/admin/edit/fundapres/models/db.py, line 8, in module
 response.cookies[response.session_id_name]['domain'] = 'website.com'
 KeyError: 'session_id_website_panel'



 Also tryied deleting the old session table and the corresponding file 
 under databases folder, but in this case again I receive an error saying 
 that the table web2py_session_website_panel doesn't exists. So I'm 
 stucked here. Any tip? Thanks in advance.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How to remove application name from urls generated from a scheduled task?

2015-04-25 Thread Lisandro
If by chance someone is dealing with the same problem and using nginx, 
here's a temporary fix: edit your virtual host configuration, and add this 
lines inside the server {} block directive:

location /appname/ {
rewrite ^/appname/(.*)$ $scheme://mydomain.com/$1 redirect;
}

El viernes, 24 de abril de 2015, 13:37:43 (UTC-3), Lisandro escribió:

 I'm using parametric based routes for mapping each domain with its 
 corresponding app. Because of this, when I use the URL() helper, the 
 application name isn't included in the resulting url, and that is perfect 
 for me. However, inside a scheduled task, the URL() helper generates urls 
 including the app name. 

 Both urls (with and without application name) work ok. But considering 
 they are urls for public content, I don't like the idea of having two 
 different urls with the same content, I think it could be 
 counter-productive for SEO and related stuff.

 Is there a way to avoid the inclusing of app name in urls generated from 
 sheduled tasks?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.