IRC logs of #tryton for Monday, 2011-12-05

chat.freenode.net #tryton log beginning Mon Dec 5 00:00:01 CET 2011
2011-12-05 00:07 <cjbarnes18> cedk: re issue2313, I think this issue is really 2, 1st concern is that the error is not clear. I had to mute each field to find that time was the problem.
2011-12-05 00:08 <cjbarnes18> cedk: 2nd is the obvious missing widget.
2011-12-05 00:08 <cjbarnes18> I dont have a use case for this I am simply trying everything out.
2011-12-05 00:09 <cjbarnes18> cedk: I have found more missing on tree views.
2011-12-05 00:09 <cedk> cjbarnes18: yes of course, all fields are not displayable in all views
2011-12-05 00:11 <cjbarnes18> would a not_supported_in_view+exception be in order do you think?
2011-12-05 00:31 <cedk> cjbarnes18: why not
2011-12-05 00:34 <cjbarnes18> cedk: ok will add this to the list, Am happy to attempt both if thats OK,
2011-12-05 13:50 <grasbauer> hi
2011-12-05 13:56 <grasbauer> someone with a shopping cart connected to tryton? how you handle the gross price shown to the client? Mostly in onlineshops there are products with a gross price - not untaxed list_prices .... still thinking about the best way to handle this ...
2011-12-05 13:58 <cedk> grasbauer: I think you must store on the product the gross price
2011-12-05 13:59 <cedk> grasbauer: and of course you can not use sale module
2011-12-05 13:59 <zxq9> Does anyone remember how to place an image into a report from a binary field in the database?
2011-12-05 14:00 <grasbauer> zxq9: widget="image"
2011-12-05 14:00 <zxq9> Into a report, not view.
2011-12-05 14:00 <zxq9> Like in an ODT
2011-12-05 14:01 <zxq9> I'm trying to follow the Relatorio and Genshi docs, but I'm getting problems.
2011-12-05 14:02 <zxq9> Like insert Frame with "image: (model.fieldname, 'image/jpeg')" and getting errors like "'buffer' object has no attribute 'seek'" after opendocument.py tries bistream.seek(0)
2011-12-05 14:03 <cedk> zxq9: must convert it into str
2011-12-05 14:04 <zxq9> image: ('model.fieldname', 'image/jpeg') ? Because that doesn't work, either. I then get "'str' object has no attribute 'seek'"
2011-12-05 14:05 <cedk> zxq9: oops, yes you must use a StringIO
2011-12-05 14:07 <grasbauer> zxq9: i did it with a method that creates StringIO.StringIO() from the data
2011-12-05 14:09 <zxq9> How did you do that?
2011-12-05 14:09 <grasbauer> zxq9: one moment
2011-12-05 14:09 <zxq9> You mean define a method in the model that I can call from the ODT which returns the correct ('image', 'mimetype')?
2011-12-05 14:10 <grasbauer> zxq9: yes
2011-12-05 14:11 <zxq9> I'm not familiar enough with Python data operations to do that without reading an example, I think.
2011-12-05 14:13 <cedk> I think we must improve relatorio to work also with str/buffer
2011-12-05 14:15 <zxq9> If we could declare mutable variables in Relatorio instead of instance constants that would be very helpful. Arbitrary loops (like a "while" with an arbitrary closing condition) would be very useful too and sort of complete the mini-language.
2011-12-05 14:16 <zxq9> At the moment with no mutable variables the only way to create an iterator is to make a list object and list.append(1) and test len(), which is really silly.
2011-12-05 14:17 <cedk> http://relatorio.openhex.org/ticket/44
2011-12-05 14:18 <cedk> zxq9: I think it is a bad practice to put code in templates
2011-12-05 14:18 <zxq9> cedk: It is, but we are already doing it when we use <for each="foo in bar">.
2011-12-05 14:19 <zxq9> cedk: Its a stupid idea to code inside a web page, but that is what people are doing also -- and that's not much different than coding in templates.
2011-12-05 14:19 <cedk> zxq9: it is quite different to have a loop and having a full assignation
2011-12-05 14:19 <zxq9> cedk: Having conditionals is great, and having for each is great, but it doesn't work when you have set-length forms instead of things like invoice forms that are allowed to grow longer with each item.
2011-12-05 14:19 <cedk> zxq9: as you say it is stupid so don't encourage it
2011-12-05 14:20 <zxq9> cedk: But its the only way to do things like properly paginate when you have a government form you must fill out which will be rejected if altered -- and it always has 20 rows, but you have 43 people, so you need 3 pages, 20 + 20 + 3.
2011-12-05 14:20 <cedk> zxq9: no, as I already told you you must fix it on the report code
2011-12-05 14:21 <zxq9> cedk: I know. And I agree. But people have bosses.
2011-12-05 14:21 <zxq9> cedk: I have had to finish this ridiculous project, writing in really crazy Relatorio code inside the report documents.
2011-12-05 14:22 <zxq9> cedk: But now... now I can make another version, with the code in a module that goes with the report, and demonstrate how that is better.
2011-12-05 14:22 <cedk> zxq9: relatorio doesn't have a boss so we do only good practice
2011-12-05 14:22 <zxq9> cedk: But without having done all this crazy Relatorio stuff I couldn't have gotten this far to even begin the argument.
2011-12-05 14:22 <zxq9> cedk: If you want people with full time employees and money to start showing up you're going to have to be a little more accomodating than that.
2011-12-05 14:24 <zxq9> cedk: The same thing with the language thing VS languages with multiple scripts. I tried doing the translation thing, by the way, but calling setLang() doesn't work beyond multiple calls in a document -- so you can't use it per-field for more than a single field (and we had hundreds).
2011-12-05 14:24 <cedk> zxq9: I don't care, I don't want to maintain crappy software
2011-12-05 14:24 <zxq9> cedk: And the multiple languages was really confusing for the customer, because there are really a lot of fields where you have to write several alphabet types. :-(
2011-12-05 14:25 <cedk> zxq9: this is the last time I said, you must *write code in report parser*
2011-12-05 14:25 <zxq9> cedk: I don't think having mutable variables and while() in Relatorio makes it crappy. I think it just completes it
2011-12-05 14:25 <cedk> zxq9: no template are not for programming !!!
2011-12-05 14:25 <cedk> zxq9: no template are not for programming !!!
2011-12-05 14:26 <zxq9> cedk: Then what is <if test=""> in there fore?
2011-12-05 14:26 <zxq9> cedk: We should remove it?
2011-12-05 14:26 <cedk> zxq9: this is not assignation !!!
2011-12-05 14:26 <zxq9> cedk: What is <with vars=""> for?
2011-12-05 14:26 <cedk> zxq9: comes from Genshi and it should not be used
2011-12-05 14:27 <zxq9> cedk: I think it would be more straightforward to be more strict then... like maybe ONLY allow calls to methods and objects inside models.
2011-12-05 14:27 <zxq9> cedk: Then there would be no choice, and everything would still be codable, just only inside the Python code.
2011-12-05 14:28 <zxq9> cedk: I don't think this is a bad way, really, so long as a few more tutorials are available/updated.
2011-12-05 14:28 <cedk> zxq9: I did not decide to include with but for sure it was a mistake
2011-12-05 14:30 <zxq9> cedk: So your vision is Relatorio dropping <with vars="">, and gaining the ability to work directly with bitstream.seek() for images?
2011-12-05 14:30 <zxq9> cedk: I dont think that is a bad thing, it just needs to be documented well.
2011-12-05 14:31 <zxq9> cedk: And maybe that means really splitting the Relatorio documentation away from constant Genshi references.
2011-12-05 14:31 <cedk> zxq9: patch is welcome
2011-12-05 14:32 <zxq9> cedk: How about documentation as well? How do I help with making Relatorio docs up to date?
2011-12-05 14:33 <cedk> zxq9: write it
2011-12-05 14:33 <zxq9> cedk: Who do I submit to?
2011-12-05 14:33 <cedk> zxq9: bugtracker
2011-12-05 14:33 <zxq9> cedk: OK.
2011-12-05 14:34 <zxq9> cedk: Next question, technical one this time -- how do I know which ids to pass to a fields.Function()? Is it usually a pyson thing?
2011-12-05 14:34 <pjstevns> v
2011-12-05 14:37 <cedk> zxq9: I don't understand
2011-12-05 14:42 <zxq9> Like in a getter(ids, name), where does ids get passed from?
2011-12-05 14:44 <cedk> zxq9: it comes from the records you are reading
2011-12-05 14:49 <zxq9> Ah... ok. This makes more sense now. It was sort of magic to me before -- which is a little scary.
2011-12-05 15:52 <zxq9> cedk: Hmmm... I'm trying to take the image data from the binary field and save it as /tmp/image.jpeg, define a file object and return it and the mime type in a function.
2011-12-05 15:52 <zxq9> cedk: Am I going in the correct direction or is this wrong to pass an image to a report?
2011-12-05 16:01 <cedk> zxq9: yes it looks like
2011-12-05 16:07 <zxq9> I'm having a 'char buffer type not available' problem, but I think there is a way to avoid this.
2011-12-05 16:08 <zxq9> I think the way I'm calling the method is actually pulling the data as a string from the server, then passing the whole thing as an argument to the method.
2011-12-05 16:08 <zxq9> I want to just call the method and have it copy the correct image from the current id into a file.
2011-12-05 16:10 <zxq9> And this is where I'm lost on the id thing.
2011-12-05 16:16 <zxq9> cedk: http://fpaste.org/GmaE/ and http://fpaste.org/4h8P/ is what is there now, but this is pulling the file data from server to client and pushing it back to write to a file to send again, I think (ridiculous).
2011-12-05 16:17 <zxq9> cedk: The binary field face_pic should just get copied once on the server side, but I don't know how to access just the current record from within a method like this.
2011-12-05 16:19 <zxq9> cedk: and of course the <image:> part is not written like that, it is the name string of a field
2011-12-05 16:19 <cedk> zxq9: why not using StringIO?
2011-12-05 16:20 <zxq9> You mean like str(binaryfield)?
2011-12-05 16:20 <zxq9> Or maybe I don't know about StringIO?
2011-12-05 16:21 <grasbauer> zxq9: StringIO.StringIO(string_from_the_binary_field)
2011-12-05 16:21 <zxq9> Ah, it is a Python library class? I neefd to rad about it.
2011-12-05 16:23 <zxq9> How would this look? http://fpaste.org/P9JE/ ?
2011-12-05 16:25 <zxq9> So StringIO is like virtual files or files in core memory?
2011-12-05 16:25 <zxq9> That's way faster than making a /tmp file
2011-12-05 16:31 <zxq9> Hmm... pic = (StringIO.StringIO(image), 'image/jpeg'); return pic; makes open office think the document is corrupted, which is interesting.
2011-12-05 16:31 <cedk> zxq9: have you the last version of relatorio?
2011-12-05 16:32 <zxq9> erm... good question. Lemme check.
2011-12-05 16:33 <zxq9> cedk: http://fpaste.org/jQbg/ Should this work or am I still doing something silly?
2011-12-05 16:33 <cedk> zxq9: it should
2011-12-05 16:34 <cedk> zxq9: but we got sometimes buffer exception because StringIO can not work on buffer from psycopg
2011-12-05 16:34 <cedk> zxq9: so adding a str conversion is good
2011-12-05 16:35 <zxq9> cedk: Like http://fpaste.org/O2PA/?
2011-12-05 16:36 <zxq9> No, I get the old str object has no seek method thing again that way. Must not be what you meant.
2011-12-05 16:36 <cedk> zxq9: no the other way
2011-12-05 16:37 <cedk> StringIO(str(image))
2011-12-05 16:37 <zxq9> oh... haha. I see.
2011-12-05 16:39 <zxq9> cedk: Calling from "image: person.person.get_pic(person.person.face_pic)" now gives a much more promising error: "'module' object is not callable'
2011-12-05 16:41 <cedk> zxq9: you can not call method on BrowseRecord
2011-12-05 16:44 <cedk> zxq9: the simple way is to put the method in the localcontext of the report parser
2011-12-05 16:45 <zxq9> cedk: Is there an example of this I can read? I'm unclear on exactly where the "report parser" is.
2011-12-05 16:47 <cedk> zxq9: http://hg.tryton.org/modules/account/file/e0e172026e46/account.py#l1167
2011-12-05 17:14 <zxq9> cedk: Weird. With an update to Relatorio this actually works without the method: <image: (StringIO(str(person.person.face_pic)), 'image/jpeg')
2011-12-05 17:15 <zxq9> cedk: And thank you for the example. This will be useful for re-writing my crazy document system!
2011-12-05 18:20 <udono> cedk: hi, what is the schedule for 2.2.1?
2011-12-05 18:21 <cedk> udono: don't know
2011-12-05 18:26 <udono> cedk: ok.
2011-12-05 19:58 -!- grasbauer(~jan@dslb-094-223-191-060.pools.arcor-ip.net) has left #tryton

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!