Hello. 
The problem was in "view_time" field. If substitute parsed value 
"view_time" from previous "get" request, all work. 
About XmlRpcPlugin. I haven't considered this variant. Our trac very loaded 
system.  And if any issue will occur or service interrupt occur my boss 
will fire me at the same moment. And besides I do not have access to the 
trac server. =)

Thank you. Your comment was very helpful  for me. You helped me a lot. 


среда, 3 мая 2017 г., 9:42:18 UTC+3 пользователь RjOllos написал:
>
>
>
> On Tuesday, May 2, 2017 at 12:46:32 PM UTC-7, Гордон Шамвей wrote:
>>
>> Hello.
>>  I want to change the card component automatically using the post request in 
>> the python.
>>  I tried everything I could and knew.
>>  But  trac gives me just only that (in any version of my code):
>>
>>  This ticket has been modified since you started editing. You should 
>>> review
>>>  the other modifications which have been appended above, and any 
>>> conflicts
>>>  shown in the preview below. You can nevertheless proceed and submit your
>>>  changes if you wish so.
>>
>>
>> I know for sure:  no one changed it. 
>>
>>  I'm at a loss. Can you help me?
>>  # _*_ coding:utf-8 _*_
>>  #!/usr/bin/python
>>  import requests
>>  from requests.auth import HTTPDigestAuth
>>  from requests.auth import HTTPBasicAuth
>>  import time
>>  def payload2(hed):
>>          payload={\
>>                  "__FORM_TOKEN" : hed,\
>>                  "__EDITOR__1" : "textarea",\
>>                  "comment" : "test",\
>>                  "field_summary" : "test",\
>>                  "__EDITOR__2" : "textarea",\
>>                  "field_description" : "",\
>>                  "field_type" : u"info",\
>>                  "field_priority" : "major",\
>>                  "field_milestone" : "",\
>>                  "field_component" : u"Info",\
>>                  "field_keywords" : "",\
>>                  "field_cc" : "",\
>>                  "action" : "leave",\
>>                  "start_time" : str(current_time),\
>>                  "view_time" : str(current_time),\
>>                  "replyto" : "",\
>>                  "submit" : "Submit+changes"\
>>                   }
>>          return payload
>>  current_time = int(time.time()*1000000)
>>  URL = "http://trac.bla-bla.com/ticket/91279";
>>  with requests.Session() as s:
>>          s = requests.Session()
>>          s.auth= ('user', 'password')
>>          login = s.get(URL)
>>          s.cookies = login.cookies
>>          hed =   login.cookies["trac_form_token"]
>>          hed = str(hed)
>>          pay = payload2(hed)
>>          ttt = requests.utils.dict_from_cookiejar(login.cookies)
>>          print_text =  s.post(URL,  data=pay, cookies=ttt)
>>          print  unicode(print_text.text).encode('utf8')
>>          print print_text.cookies
>>          print requests.utils.dict_from_cookiejar(login.cookies)
>>
>>  But ticket does not change. 
>>
>
> You'll need to know the ticket changetime:
>
> https://trac.edgewall.org/browser/tags/trac-1.2.1/trac/ticket/web_ui.py?marks=1297,1298#L1295
> It's a hidden field of the ticket page.
>
> Have you considered using XmlRpcPlugin?
>
> https://trac-hacks.org/wiki/XmlRpcPlugin
>
> - Ryan
>
>

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to