[web2py] Re: web2py/pydal.Download uploaded file error when the original filename of uploaded file is chinese cha
https://github.com/web2py/web2py/pull/1575 solved this problem. 在 2017年3月2日星期四 UTC+8下午7:01:10,Marlysson Silva写道: > > Appers some error ticket with a message? Or just just "server error" .. > > Em quarta-feira, 1 de março de 2017 23:52:54 UTC-3, Yibing Liu escreveu: >> >> I am using web2py. I cloned the latest version of pydal. I define a >> 'upload' field in my table. Then I upload a image whose filename is chinese >> character. Everything seems ok so far. However when I try to access the >> uploaded file with the download function, I get a server error. I have >> found two solutions to avoid this error. The first solution is changing the >> fllename to english character, the second solution is downgradeing the >> pydal to the older version embedded in web2py(2.14.6,release at >> May,10,2016). So I guess something is wrong in the latest pydal when >> handling filename with chinese character. Hope to get your answer. 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.
[web2py] Re: new experimental feature in trunk - rows.join(...)
You can try mu plugin https://github.com/dz0/web2py_grand_helpers/blob/master/plugins/modules/plugin_joins_builder/joins_builder.py Also mentioned as proposal https://github.com/web2py/pydal/issues/432 -- 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: Autoincrement which resets each month (not primary id)
First of all, at the risk of asking a silly question - is there actually a reason to store this secondary ID in the database rather than just have it calculated on the fly as-needed using a virtual field? Assuming that you've got a created_date field already in the table that'll give you the month portion and then there's definitely an id field to give you that so just let web2py figure it out for you on-the-fly Field.Virtual('human_id', lambda row: int(row.your_table.created_date. strftime('%y%m0')) + row.your_table.id) The above would cause a record created today (2017-03-05) that had id = 123 to return a human_id of 170300123 which is I think what you want. Note the extra zeros tacked on to the end of the strftime they are important so that when you add the ID you don't accidentally increment your month number - be sure to include enough to ensure that you can cover the highest realistic record ID (and then add an extra zero :D). Alternatively, you may wish to consider changing your human ID format to something like yymm-## so that you don't have to worry about inadvertently messing up your date related portion and it is perhaps slightly easier for humans to understand which is presumably important because I don't get why you'd want to include the year and month if it isn't supposed to mean anything to the user. db.your_table.human_id = Field.Virtual('human_id', lambda row: '{0}-{1}'.format(row.your_table.created_date.strftime('%y%m') +'-' + row. your_table.id), table_name = 'your_table') If you need to actually store it in the database then you'll have to work more. Sadly, web2py's computed fields won't work because they don't know the ID before the insert. That leaves you with doing it DB side. MySQL appears to only lets you have one auto-increment per table so unfortunately you can't have both your actual primary key ID and a second human readable monthly ID (that would intentionally be reset to something like 170300 this month and 170400 next). What I'd consider is creating a DB trigger that would take care of automatically populating your secondary ID for you all within the database so that there's nothing for you to manage. So on insert the database could automatically look at the date (or use an existing created_date field) and the current auto-increment number and combine as needed and store it for you. ~Brian On Sunday, March 5, 2017 at 11:26:51 AM UTC-6, Paul Ellis wrote: > > I want to have a numbering system which is 2 digit year, 2 digit month and > then an autoincrement number which resets each month. 1703# > > Currently using SQLite with a view to move to MYSQL in future. The MYSQL > examples I have found suggest using a composite primary key, which doesn't > seem to fit too well with web2py. > > The reason I am trying for autoincrement is so the database ensures the > numbers are unique. I am willing to look at another way if I am sure I > won't end up with 2 identical numbers. > > At the moment I have it working with > datetime.date.today().strftime('%y%m') + id. So I am half way there, but > can't see how to reset each month. I guess I can check for the highest > number in the database programmatically, but I am worried about duplicate > numbers with a high number of users. This also seems like if the document > with the highest number was deleted (but possibly already printed), then > the number will be reused. > > The program uses the actual primary key for all backend work. This is just > an identifier for humans, but the documents produced by the program can't > afford to have the same number as another document. > > Can someone give me a nudge in the right direction, I am a bit stuck? > -- 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: Autoincrement which resets each month (not primary id)
perhaps you can use count *e.g.* count_invoice = db.invoice.id.count() this_year = request.now.year this_month = request.now.month query_invoice = ((db.invoice.invoice_date.year() == this_year) & (db.invoice.invoice_date.month() == this_month) ) query_count_invoice = db(query_invoice).select(count_invoice).first()[count_invoice] if db(query_invoice).select() else 0 invoice_no_count = int(query_count_invoice) + 1 if query_count_invoice else 1 invoice_no_format_count = format(invoice_no_count, '05') invoice_no = request.now.strftime('%y%m')+invoice_no_format_count 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] Re: javascript prompt and modal dialog
What you make until here..? Em domingo, 5 de março de 2017 15:29:29 UTC-3, Andrea Fae' escreveu: > > I need to open a jquery Dialog from inside a Select javascript in a view > web2py, taking some values from javascript, At closing dialog with OK I > need to insert record about the fields of this dialog to a database. > Thank you > > Il giorno martedì 28 febbraio 2017 06:00:55 UTC+1, Marlysson Silva ha > scritto: >> >> The steps that your would made. >> >> The modal would be the form within a div , this div would have the >> trigger to activate the modal ( using sweetalert ) , then in the form ( >> within a modal ) you connect the function on controller receiving data from >> form and processing . >> >> >> >> Em quinta-feira, 23 de fevereiro de 2017 16:09:08 UTC-3, Andrea Fae' >> escreveu: >>> >>> When I click function select I want that appears a modal dialog using >>> jquery, asking some fields, and using this fields passing to controller >>> >>> Il giorno mercoledì 22 febbraio 2017 17:23:51 UTC+1, Ramos ha scritto: i like this one https://limonte.github.io/sweetalert2/ and im using it with web2py 2017-02-22 13:44 GMT+00:00 Marlysson Silva: > Explain more your problem? > > You are using just javascript or want integrate with web2py? > > > Em sábado, 18 de fevereiro de 2017 16:11:30 UTC-3, Andrea Fae' > escreveu: >> >> Hello. >> From Javascript I need to ask some different values and promt is good >> only for 1 text box. >> >> I know that I have to use jqury modal dialog, but I don't know >> nothing about it (I need to study?) >> >> Is there anyone that can write me a very simple example? You have to >> know that I have to use with select function in Fullcalendar scheduler >> addon. >> >> 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+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 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: javascript prompt and modal dialog
I need to open a jquery Dialog from inside a Select javascript in a view web2py, taking some values from javascript, At closing dialog with OK I need to insert record about the fields of this dialog to a database. Thank you Il giorno martedì 28 febbraio 2017 06:00:55 UTC+1, Marlysson Silva ha scritto: > > The steps that your would made. > > The modal would be the form within a div , this div would have the trigger > to activate the modal ( using sweetalert ) , then in the form ( within a > modal ) you connect the function on controller receiving data from form and > processing . > > > > Em quinta-feira, 23 de fevereiro de 2017 16:09:08 UTC-3, Andrea Fae' > escreveu: >> >> When I click function select I want that appears a modal dialog using >> jquery, asking some fields, and using this fields passing to controller >> >> Il giorno mercoledì 22 febbraio 2017 17:23:51 UTC+1, Ramos ha scritto: >>> >>> i like this one >>> https://limonte.github.io/sweetalert2/ >>> and im using it with web2py >>> >>> 2017-02-22 13:44 GMT+00:00 Marlysson Silva: >>> Explain more your problem? You are using just javascript or want integrate with web2py? Em sábado, 18 de fevereiro de 2017 16:11:30 UTC-3, Andrea Fae' escreveu: > > Hello. > From Javascript I need to ask some different values and promt is good > only for 1 text box. > > I know that I have to use jqury modal dialog, but I don't know nothing > about it (I need to study?) > > Is there anyone that can write me a very simple example? You have to > know that I have to use with select function in Fullcalendar scheduler > addon. > > 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+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 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] Autoincrement which resets each month (not primary id)
I want to have a numbering system which is 2 digit year, 2 digit month and then an autoincrement number which resets each month. 1703# Currently using SQLite with a view to move to MYSQL in future. The MYSQL examples I have found suggest using a composite primary key, which doesn't seem to fit too well with web2py. The reason I am trying for autoincrement is so the database ensures the numbers are unique. I am willing to look at another way if I am sure I won't end up with 2 identical numbers. At the moment I have it working with datetime.date.today().strftime('%y%m') + id. So I am half way there, but can't see how to reset each month. I guess I can check for the highest number in the database programmatically, but I am worried about duplicate numbers with a high number of users. This also seems like if the document with the highest number was deleted (but possibly already printed), then the number will be reused. The program uses the actual primary key for all backend work. This is just an identifier for humans, but the documents produced by the program can't afford to have the same number as another document. Can someone give me a nudge in the right direction, I am a bit stuck? -- 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: New system like web2pyslices ( redesign and remodel maybe ) to web2py
Like code example section? Em domingo, 5 de março de 2017 10:14:54 UTC-3, Ben Lawrence escreveu: > > I prefer we keep everything in the web2py book with extra long code in > github. Example code can all go into the book. People go there. It is good. > > I tried to contribute to the book > https://github.com/web2py/web2py-book/pull/351 > but received no feedback. Is this the right way to do it? > > On Tuesday, February 28, 2017 at 5:13:57 AM UTC-8, Leonel Câmara wrote: >> >> Created an account just for this last night, need to start working >> towards that 150 reputation. >> > -- 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: New system like web2pyslices ( redesign and remodel maybe ) to web2py
I prefer we keep everything in the web2py book with extra long code in github. Example code can all go into the book. People go there. It is good. I tried to contribute to the book https://github.com/web2py/web2py-book/pull/351 but received no feedback. Is this the right way to do it? On Tuesday, February 28, 2017 at 5:13:57 AM UTC-8, Leonel Câmara wrote: > > Created an account just for this last night, need to start working towards > that 150 reputation. > -- 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: ProgrammingError: column "worker_stats__tmp" is of type json but expression is of type text
OK, I have two machines, one with web2py+nginx (machine A) and the other with postgresql (machine B) On machine A: I check migrate = 0 I delete all the scheduler tables I check that I deleted all the scheduler tables On machine B: I delete all the scheduler tables in postgres On machine A: I check that there are no scheduler tables. I reboot it I check that there are no scheduler tables I turn on migrate = 1 There are now scheduler tables. I go to scheduler tables in web2py admin, scheduler_tasks show new tasks that have since completed, scheduler_run show new tasks that have completed, but scheduler_worker has error: Traceback (most recent call last): File "/home/www-data/web2py/applications/temperature/controllers/appadmin.py:select", line 270, in select File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 2045, in select return adapter.select(self.query, fields, attributes) File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 746, in select return self._select_aux(sql, fields, attributes, colnames) File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 727, in _select_aux return processor(rows, fields, colnames, cacheable=cacheable) File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 305, in parse for row in rows File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 229, in _parse value = self.parse_value(value, fit, ft, blob_decode) File "/home/www-data/web2py/gluon/packages/dal/pydal/adapters/base.py", line 196, in parse_value return self.parser.parse(value, field_itype, field_type) File "/home/www-data/web2py/gluon/packages/dal/pydal/parsers/__init__.py", line 101, in parse return self.registered[field_itype](value, field_type) File "/home/www-data/web2py/gluon/packages/dal/pydal/parsers/__init__.py", line 76, in __call__ return self.call(value, field_type) File "/home/www-data/web2py/gluon/packages/dal/pydal/parsers/__init__.py", line 73, in _call return self.f(self.parser, value) File "/home/www-data/web2py/gluon/packages/dal/pydal/parsers/base.py", line 129, in _json raise RuntimeError('json data not a string') RuntimeError: json data not a string On Friday, August 26, 2016 at 4:41:38 PM UTC-7, Ben Lawrence wrote: > > Thanks, I must have got the sequence wrong. > > On Thursday, August 25, 2016 at 12:05:38 PM UTC-7, Niphlod wrote: >> >> if you get any error with __tmp is because you didn't drop tables on the >> backend AND .table files before hitting the app with migrate=True. >> >> On Thursday, August 25, 2016 at 6:53:07 PM UTC+2, Ben Lawrence wrote: >>> >>> Hi Niphlod, >>> I deleted all the scheduler tables , created a new database and then >>> rebooted with DAL(..migrate=True..) yet still get this error >>> column "worker_stats__tmp" is of type json but expression is of type >>> text' >>> >>> using postgresql 9.4 on raspberry pi. >>> In >>> http://stackoverflow.com/questions/32501027/casting-text-type-column-to-json-type-in-postgresql >>> there is a mention of recasting. If this is a solution, would you know >>> how I can incorporate this into web2py? >>> thanks, >>> Ben >>> >>> >>> On Wednesday, May 27, 2015 at 12:53:40 PM UTC-7, Niphlod wrote: Please drop the scheduler_worker table from the database and remove the file *_scheduler_worker.table from the databases/ folder of your application, then set migrate to True (a single request with migrate=True will suffice). The table will be recreated properly and the error will go away. The error comes from the fact that the adapter chooses "at connection time" the "nicest" column type to play with based on the backend version. The definition of the scheduler_worker table has a "json" Field, that on postgresql 9.3 maps to a "json" column, while on 9.1 was a "text" column, hence the misbehaviour if you don't drop and re-create the table. -- 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.