spiderfw 0.6.28 → 0.6.29

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.6.29
2
+ * Sostituito metodo lambda per problemi con ruby 1.9.3 in site_map del cms
3
+ * Cambiata gestione invio sms con sender_name e prefisso internazionele, mail (smpt -> smtp )
4
+ * Modifiche alla widget table per paginazione per gestione pagina di dettaglio e ritorno a pagina corrente in elenco
5
+ * Corretto db_mapper per condition sugli elementi di un modello
6
+
1
7
  == 0.6.28
2
8
  * Visualizzazione in core:table dei dati collegati, eliminazione dipendenze circolari in uow
3
9
  * Bugfixes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.28
1
+ 0.6.29
@@ -71,7 +71,6 @@ module Spider; module Components
71
71
  @widgets[:ask_delete].scene.rows_to_del = rows
72
72
  end
73
73
  elsif @action == :form
74
- # debugger
75
74
  if @widgets[:form].saved?
76
75
  flash[:saved] = true
77
76
  if @widgets[:form].saved_and_new?
@@ -67,6 +67,7 @@ module Spider; module Components
67
67
  end
68
68
  @sort_el = [@sort_el] if @sort_el && !@sort_el.is_a?(Array)
69
69
  @scene.link_el = @attributes[:link_el]
70
+ @scene.current_page = @page
70
71
  @scene.link = @attributes[:link]
71
72
  @scene.link_id = @attributes[:link_id] || @attributes[:link_el]
72
73
  super
@@ -15,9 +15,15 @@
15
15
  <tpl:pass sp:each_index="@rows |row_i|">
16
16
  <tr class="{ (row_i%2==0) ? 'odd' : 'even' }">
17
17
  <td sp:each="@elements |element|">
18
- <a sp:tag-if="@link_el && element == @link_el" href="{ @link }{ Spider::HTTP.urlencode(@data[row_i][@link_id]) }">
18
+ <a sp:if="((!@link_el.blank? && element == @link_el) && @link.blank?)" href="{ Spider::HTTP.urlencode(@data[row_i][@link_id]) }?current_page={ @page }">
19
+ { @rows[row_i][element] }
20
+ </a>
21
+ <a sp:if="@link_el && element == @link_el && !@link.blank?" href="{ @link }{ Spider::HTTP.urlencode(@data[row_i][@link_id]) }&current_page={ @page }">
19
22
  { @rows[row_i][element] }
20
23
  </a>
24
+ <span sp:if="element != @link_el" >
25
+ { @rows[row_i][element] }
26
+ </span>
21
27
  </td>
22
28
  </tr>
23
29
  </tpl:pass>
@@ -20,7 +20,7 @@ module Spider; module Messenger; module Backends; module Email
20
20
  :user_name => Spider.conf.get('messenger.smtp.username'),
21
21
  :password => Spider.conf.get('messenger.smtp.password'),
22
22
  :authentication => Spider.conf.get('messenger.smtp.auth_scheme'),
23
- :enable_starttls_auto => Spider.conf.get('messenger.smpt.enable_starttls_auto')
23
+ :enable_starttls_auto => Spider.conf.get('messenger.smtp.enable_starttls_auto')
24
24
  }
25
25
  mail.deliver
26
26
  return true
@@ -7,7 +7,7 @@ module Spider
7
7
  config_option 'messenger.smtp.password', _("SMTP authentication password"), :default => nil
8
8
  config_option 'messenger.smtp.auth_scheme', _("SMTP authentication scheme"), :default => nil, :type => Symbol,
9
9
  :choices => [nil, :plain, :login, :cram_md5]
10
- config_option 'messenger.smpt.enable_starttls_auto', _("Automatically start TLS for SMTP"), :default => false, :type => Spider::Bool
10
+ config_option 'messenger.smtp.enable_starttls_auto', _("Automatically start TLS for SMTP"), :default => false, :type => Spider::Bool
11
11
  config_option 'messenger.smtp.log_path', _("Smtp logfile (e.g. /var/log/mail.log)"), :default => nil
12
12
 
13
13
  config_option 'messenger.email.retries', _("How many times to retry sending an e-mail"), :type => Fixnum, :default => 5
@@ -27,6 +27,7 @@ module Spider; module Messenger
27
27
  end
28
28
 
29
29
  def send_sms(to, text, params={})
30
+ to = "+39"+to if !to.include?("+")
30
31
  msg = Spider::Messenger.sms(to, text, params)
31
32
  sent_sms(msg.ticket)
32
33
  msg
@@ -132,9 +132,9 @@ module Spider
132
132
  return msg
133
133
  end
134
134
 
135
- def self.sms(to, text, params={})
135
+ def self.sms(to, text, sender_name=nil, params={})
136
136
  msg = SMS.new(
137
- :to => to, :text => text
137
+ :to => to, :text => text, :sender_name => sender_name
138
138
  )
139
139
  msg.next_try = params[:send_from] || DateTime.now
140
140
  msg.save
@@ -4,6 +4,7 @@ module Spider; module Messenger
4
4
 
5
5
  class SMS < Message
6
6
  class_table_inheritance :add_polymorphic => true
7
+ element :sender_name, String, :label => "Nome Ente"
7
8
  element :to, String, :label => _("To")
8
9
  element :text, Text, :label => _("Text")
9
10
 
@@ -13,13 +13,13 @@
13
13
  <div sp:if="@queue == :sms" class="queue">
14
14
  <h4>_(Sent messages) - { @sent.total_rows }</h4>
15
15
  <core:table id='sent' queryset='@sent' row_limit="5" link="@msg_view_url" link_el="id"
16
- elements="id,to,ticket,sent,text" sort="sent,desc"/><br>
16
+ elements="id,to,sender_name,ticket,sent,text" sort="sent,desc"/><br>
17
17
  <h4>_(Queued messages) - { @queued.total_rows }</h4>
18
18
  <core:table id='queued' queryset='@queued' row_limit="5" link="@msg_view_url" link_el="id"
19
- elements="id,to,ticket,last_try,next_try,attempts,backend_response" sort="next_try,desc"/><br>
19
+ elements="id,to,sender_name,ticket,last_try,next_try,attempts,backend_response" sort="next_try,desc"/><br>
20
20
  <h4>_(Failed messages) - { @failed.total_rows }</h4>
21
21
  <core:table id='failed' queryset='@failed' row_limit="5" link="@msg_view_url" link_el="id"
22
- elements="id,to,ticket,last_try,backend_response" sort="last_try,desc"/><br>
22
+ elements="id,to,sender_name,ticket,last_try,backend_response" sort="last_try,desc"/><br>
23
23
  </div>
24
24
 
25
25
  </div>
@@ -262,6 +262,7 @@ module Spider; module Model
262
262
 
263
263
  orig_type = type
264
264
  assoc_type = nil
265
+ attributes[:reverse] ||= attributes[:reverse_of]
265
266
  if (proc || attributes[:junction] || (attributes[:multiple] && (!attributes[:add_reverse]) && (!attributes[:has_single_reverse]) && \
266
267
  # FIXME! the first check is needed when the referenced class has not been parsed yet
267
268
  # but now it assumes that the reverse is not multiple if it is not defined
@@ -1174,7 +1174,7 @@ module Spider; module Model; module Mappers
1174
1174
  column.primary_key = true if element.primary_key?
1175
1175
  schema.set_column(element.name, column)
1176
1176
  elsif (true) # FIXME: must have condition element.storage == @storage in some of the subcases
1177
- if (!element.multiple? && !element.attributes[:junction] && !element.attributes[:condition]) # 1/n <-> 1
1177
+ if (!element.multiple? && !element.attributes[:junction] && !element.attributes[:reverse_of]) # 1/n <-> 1
1178
1178
  current_schema = schema.foreign_keys[element.name] || {}
1179
1179
  foreign_key_constraints = {}
1180
1180
  el_mapper = element.type.mapper
@@ -279,15 +279,20 @@ module Spider; module Model
279
279
  prev_autoload = obj.autoload?
280
280
  obj.save_mode
281
281
  storage.in_transaction
282
- save_mode = determine_save_mode(obj)
283
- before_save(obj, save_mode)
284
- if save_mode == :update
285
- do_update(obj)
286
- else
287
- do_insert(obj)
282
+ begin
283
+ save_mode = determine_save_mode(obj)
284
+ before_save(obj, save_mode)
285
+ if save_mode == :update
286
+ do_update(obj)
287
+ else
288
+ do_insert(obj)
289
+ end
290
+ after_save(obj, save_mode)
291
+ storage.commit_or_continue
292
+ rescue
293
+ storage.rollback_or_continue
294
+ raise
288
295
  end
289
- after_save(obj, save_mode)
290
- storage.commit_or_continue
291
296
  obj.autoload = prev_autoload
292
297
  unless @doing_save_done
293
298
  @doing_save_done = true
@@ -466,10 +471,15 @@ module Spider; module Model
466
471
  def insert(obj)
467
472
  prev_autoload = obj.save_mode()
468
473
  storage.in_transaction
469
- before_save(obj, :insert)
470
- do_insert(obj)
471
- after_save(obj, :insert)
472
- storage.commit_or_continue
474
+ begin
475
+ before_save(obj, :insert)
476
+ do_insert(obj)
477
+ after_save(obj, :insert)
478
+ storage.commit_or_continue
479
+ rescue
480
+ storage.rollback_or_continue
481
+ raise
482
+ end
473
483
  obj.autoload = prev_autoload
474
484
  end
475
485
 
@@ -479,10 +489,15 @@ module Spider; module Model
479
489
  def update(obj)
480
490
  prev_autoload = obj.save_mode()
481
491
  storage.in_transaction
482
- before_save(obj, :update)
483
- do_update(obj)
484
- after_save(obj, :update)
485
- storage.commit_or_continue
492
+ begin
493
+ before_save(obj, :update)
494
+ do_update(obj)
495
+ after_save(obj, :update)
496
+ storage.commit_or_continue
497
+ rescue
498
+ storage.rollback_or_continue
499
+ raise
500
+ end
486
501
  obj.autoload = prev_autoload
487
502
  end
488
503
 
@@ -504,7 +519,7 @@ module Spider; module Model
504
519
  # Useful when an object will be re-inserted with the same keys.
505
520
  # @return [void]
506
521
  def delete(obj_or_condition, force=false, options={})
507
-
522
+
508
523
  def prepare_delete_condition(obj)
509
524
  condition = Condition.and
510
525
  @model.primary_keys.each do |key|
@@ -536,36 +551,41 @@ module Spider; module Model
536
551
  before_delete(curr)
537
552
  vals = []
538
553
  started_transaction = false
539
- unless cascade.empty? && assocs.empty?
540
- storage.in_transaction
541
- started_transaction = true
542
- curr.each do |curr_obj|
543
- obj_vals = {}
544
- cascade.each do |el|
545
- obj_vals[el] = curr_obj.get(el)
546
- end
547
- vals << obj_vals
548
- assocs.each do |el|
549
- next if el.has_single_reverse? && options[:keep_single_reverse]
550
- delete_element_associations(curr_obj, el)
554
+ begin
555
+ unless cascade.empty? && assocs.empty?
556
+ storage.in_transaction
557
+ started_transaction = true
558
+ curr.each do |curr_obj|
559
+ obj_vals = {}
560
+ cascade.each do |el|
561
+ obj_vals[el] = curr_obj.get(el)
562
+ end
563
+ vals << obj_vals
564
+ assocs.each do |el|
565
+ next if el.has_single_reverse? && options[:keep_single_reverse]
566
+ delete_element_associations(curr_obj, el)
567
+ end
551
568
  end
552
569
  end
553
- end
554
- @model.referenced_by_junctions.each do |junction, element|
555
- curr.each do |curr_obj|
556
- junction_condition = Spider::Model::Condition.new
557
- junction_condition[element] = curr_obj
558
- junction.mapper.delete(junction_condition)
570
+ @model.referenced_by_junctions.each do |junction, element|
571
+ curr.each do |curr_obj|
572
+ junction_condition = Spider::Model::Condition.new
573
+ junction_condition[element] = curr_obj
574
+ junction.mapper.delete(junction_condition)
575
+ end
559
576
  end
560
- end
561
- do_delete(condition, force)
562
- vals.each do |obj_vals|
563
- obj_vals.each do |el, val|
564
- el.model.mapper.delete(val)
577
+ do_delete(condition, force)
578
+ vals.each do |obj_vals|
579
+ obj_vals.each do |el, val|
580
+ el.model.mapper.delete(val)
581
+ end
565
582
  end
583
+ after_delete(curr)
584
+ storage.commit_or_continue if started_transaction
585
+ rescue
586
+ storage.rollback_or_continue if started_transaction
587
+ raise
566
588
  end
567
- after_delete(curr)
568
- storage.commit_or_continue if started_transaction
569
589
  end
570
590
 
571
591
  # Deletes all objects from the storage.
@@ -364,6 +364,14 @@ module Spider; module Model; module Storage
364
364
  curr[:savepoints] = []
365
365
  release
366
366
  end
367
+
368
+ def rollback_or_continue
369
+ if curr[:transaction_nesting] == 1
370
+ rollback
371
+ else
372
+ curr[:transaction_nesting] -= 1 if curr[:transaction_nesting] > 1
373
+ end
374
+ end
367
375
 
368
376
  # @abstract
369
377
  # Implemented by subclasses to interact with the backend
@@ -92,12 +92,12 @@ module Spider; module Model; module Storage; module Db
92
92
  def release
93
93
  begin
94
94
  #Spider::Logger.debug("MYSQL #{self.object_id} in thread #{Thread.current} releasing connection #{@conn}")
95
- @conn.autocommit(true) if @conn && !Spider.conf.get('storage.db.shared_connection')
95
+ curr[:conn].autocommit(true) if curr[:conn] && !Spider.conf.get('storage.db.shared_connection')
96
96
  super
97
97
  rescue => exc
98
- Spider::Logger.error("MYSQL #{self.object_id} in thread #{Thread.current} exception #{exc.message} while trying to release connection #{@conn}")
99
- self.class.remove_connection(@conn, @connection_params)
100
- @conn = nil
98
+ Spider::Logger.error("MYSQL #{self.object_id} in thread #{Thread.current} exception #{exc.message} while trying to release connection #{curr[:conn]}")
99
+ self.class.remove_connection(curr[:conn], @connection_params)
100
+ curr[:conn] = nil
101
101
  end
102
102
  end
103
103
 
@@ -8,7 +8,7 @@ module Spider; module TemplateBlocks
8
8
  init = ""
9
9
  lambda_name = @el.attributes['sp:lambda']
10
10
  @el.remove_attribute('sp:lambda')
11
- c = "#{lambda_name} = lambda do\n"
11
+ c = "#{lambda_name} = Proc.new do\n"
12
12
  content = Spider::TemplateBlocks.parse_element(@el, @allowed_blocks, @template).compile(options)
13
13
  content.run_code.each_line do |line|
14
14
  c += ' '+line
@@ -290,11 +290,10 @@ module Spider
290
290
  def widget_target=(target)
291
291
  @widget_target = target
292
292
  end
293
-
293
+
294
294
  def widget_request_path
295
295
  p = @request.path
296
- i = p.index(@_action) if @_action && !@_action.empty?
297
- p = p[0..i-2] if i
296
+ p = p.sub(/\/#{Regexp.escape(@_action)}$/, '') unless @_action.blank?
298
297
  p = p.sub(/\/+$/, '')
299
298
  return p
300
299
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiderfw
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 28
10
- version: 0.6.28
9
+ - 29
10
+ version: 0.6.29
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ivan Pirlik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-13 00:00:00 Z
18
+ date: 2013-10-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: cmdparse